Intersection testing in a ray tracing system using three-dimensional axis-aligned box

ABSTRACT

Determining whether a ray intersects a 3D axis-aligned box identifies the front-facing plane of the box which intersects the ray at a position furthest along a direction of the ray. Whether the ray intersects the box is determined by whether the ray intersects the identified front-facing plane at a position that is no further along the ray than positions at which the ray intersects the back-facing planes in a subset of the dimensions. The subset of dimensions comprises the two dimensions for which the front-facing plane was not identified, but does not comprise the dimension for which the front-facing plane was identified. Whether the ray intersects the box is determined without performing a test to determine whether the ray intersects the identified front-facing plane at a position that is no further along the ray than a position at which the ray intersects the back-facing plane in the front-facing plane dimension.

FIELD

The present disclosure is directed to techniques of performingintersection testing in a ray tracing system.

BACKGROUND

Ray tracing is a computational rendering technique for generating animage of a scene (e.g. a 3D scene) by tracing paths of light (‘rays’)usually from the viewpoint of a camera through the scene. Each ray ismodelled as originating from the camera and passing through a pixel intothe scene. As a ray traverses the scene it may intersect objects withinthe scene. The interaction between a ray and an object it intersects canbe modelled to create realistic visual effects. For example, in responseto determining an intersection of a ray with an object, a shader program(i.e. a portion of computer code) may be executed in respect of theintersection. A programmer can write the shader program to define howthe system reacts to the intersection which may, for example cause oneor more secondary rays to be emitted into the scene, e.g. to represent areflection of the ray off the intersected object or a refraction of theray through the object (e.g. if the object is transparent ortranslucent). As another example, the shader program could cause one ormore rays to be emitted into the scene for the purposes of determiningwhether the object is in shadow at the intersection point. The result ofexecuting the shader program (and processing the relevant secondaryrays) can be the calculation of a colour value for the pixel the raypassed through.

Rendering an image of a scene using ray tracing may involve performingmany intersection tests, e.g. billions of intersection tests forrendering an image of a scene. In order to reduce the number ofintersection tests that need to be performed, ray tracing systems cangenerate acceleration structures, wherein each node of an accelerationstructure represents a region within the scene. Acceleration structuresare often hierarchical (e.g. having a tree structure) such that theyinclude multiple levels of nodes, wherein nodes near the top of theacceleration structure represent relatively large regions in the scene(e.g. the root node may represent the whole scene), and nodes near thebottom of the acceleration structure represent relatively small regionsin the scene. A “tree node” refers to a node which has pointers to othernodes in the hierarchical acceleration structure, i.e. a tree node haschild nodes in the hierarchical acceleration structure. A “leaf node”refers to a node which has one or more pointers to one or moreprimitives, i.e. a leaf node does not have child nodes in thehierarchical acceleration structure. In other words, leaf nodes of theacceleration structure represent regions bounding one or more primitivesin the scene. The acceleration structure can have different structuresin different examples, e.g. a grid structure, an octree structure, aspace partitioning structure (e.g. a k-d tree) or a bounding volumehierarchy. The nodes can represent suitable shapes or regions in thescene (which may be referred to herein as “boxes”). In some examples thenodes represent axis-aligned bounding boxes (AABBs) in the scene.

Intersection testing can be performed for a ray (e.g. in a recursivemanner) using the acceleration structure by first testing the ray forintersection with the root node of the acceleration structure. If theray is found to intersect a parent node (e.g. the root node), testingcan then proceed to the child nodes of that parent. In contrast, if theray is found not to intersect a parent node, intersection testing of thechild nodes of that parent node can be avoided, saving computationaleffort. If a ray is found to intersect a leaf node then it can be testedagainst the objects within the region represented by the leaf node tothereby determine which object(s) the ray intersects with. If more thanone intersection is found for a ray then the closest of the intersectionpoints to the ray's origin (i.e. the first intersection that the rayencounters in the scene) may be identified and the ray may be determinedto intersect at this identified closest intersection. It is possiblethat there may be multiple closest hits for a ray, and in this case sometie-break logic may be used to select one of the multiple closest hitsto use as the identified closest intersection. For some types of rays,the closest intersection might not need to be identified. For example,when processing shadow rays, an indication that there is at least oneintersection is sufficient, without determining which of theintersections is the closest, and some APIs may allow the traversal ofan acceleration structure for shadow rays to be terminated in responseto finding any intersection, to thereby reduce the number ofintersection tests that need to be performed. The use of an accelerationstructure (rather than testing rays directly with objects in the scene)reduces the number of intersection tests that need to be performed, andsimplifies the intersection tests. The intersection tests are simplerbecause the nodes of the acceleration structure represent basic shapes(e.g. axis-aligned bounding boxes or spheres) for which intersectiontests are simpler than for more complex object shapes, e.g. defined interms of triangular primitives for which the alignment relative to theaxes of the coordinate system is not predetermined.

A ray (r) can be defined as r=O+Dt where O is a vector which representsthe ray origin, D is a vector which represents the ray direction and trepresents a distance along the ray from the origin. According to oneapproach a ray can be tested against an axis-aligned box by finding, foreach of the x, y and z dimensions, an interval of t for which the ray isbetween the two planes representing the sides of the box which areperpendicular to that dimension. This gives three intervals for valuesof t (one for the x dimension, one for the y dimension and one for the zdimension). If the intersection of these three intervals (itself aninterval) is empty then the ray does not intersect the axis-aligned box;whereas if the intersection of these three intervals is not empty thenthe ray may intersect the axis-aligned box. This intersection testingmethod involves performing six tests to find the three intervals of t,and then a comparison to determine whether the intersection of thoseintervals is empty.

According to another approach, a ray can be tested against the edges ofa box that form a 2D silhouette of the box from the viewpoint of theray. If the ray passes on the inside of each of the silhouette edges,then it is determined that the ray intersects the box, whereas if theray passes on the outside of one or more of the silhouette edges of thebox then it is determined that the ray does not intersect the box. AnAABB normally has 6 silhouette edges (depending upon the orientation ofthe AABB from the viewpoint of the ray), so this approach normallyrequires six tests to be performed.

The tests described above would determine whether an infinitely longline aligned with the ray would intersect the box. However, a ray is nottypically infinite in length, and may have one or more valid intervals.For example, a ray may have some minimum distance and some maximumdistance from the ray origin, which may be defined in terms of a minimumvalue of t (referred to as a minimum culling distance, t_(min)), and amaximum value of t (referred to as a maximum culling distance, t_(max)).Therefore, a minimum distance test may be performed to check that theminimum culling distance is not greater than a largest intersectiondistance to an intersection point of the ray with a box; and a maximumdistance test may be performed to check that the maximum cullingdistance is not less than a smallest intersection distance to anintersection point of the ray with the box. In the first exampledescribed above, in which intersecting intervals are used to determinewhether a ray intersects a box, rather than performing separate minimumdistance and maximum distance tests, a starting interval may beinitialised to represent a range of t values between t_(min) andt_(max), such that the result of determining whether there is anyintersection between the intervals will only determine that there is anintersection if an intersection occurs for a value of t between t_(min)and t_(max). Each of the endpoints of the range t_(min) and t_(max) caneither be included or excluded from the interval.

Since intersection tests of rays against shapes corresponding to thenodes of an acceleration structure, e.g. axis-aligned boxes, areperformed many times, it can be beneficial to implement thefunctionality for performing these intersection tests in dedicatedhardware modules, e.g. using fixed function circuitry, rather thanimplementing these intersection tests using software modules executed ongeneral purpose processing units. Software implementations generallyprovide more flexibility because software is more easily altered afterit is designed and/or created than hardware implementations are.However, hardware implementations generally provide more efficientimplementations in terms of latency and power consumption, so if thedesired functionality is known in advance, hardware implementations maybe preferred over software implementations. When designing a hardwareimplementation of an intersection testing module which is configured forperforming intersection testing there are generally competing aims ofhaving: (i) a smaller size (i.e. smaller silicon area), (ii) a lowerlatency, and (iii) lower power consumption.

SUMMARY

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

Methods and intersection testing modules are provided for determining,in a ray tracing system, whether a ray intersects a 3D axis-aligned boxrepresenting a volume defined by a front-facing plane and a back-facingplane for each dimension. The front-facing plane of the box whichintersects the ray furthest along the ray is identified. It isdetermined whether the ray intersects the identified front-facing planeat a position that is no further along the ray than positions at whichthe ray intersects the back-facing planes in a subset of the dimensions,and this determination is used to determine whether the ray intersectsthe axis-aligned box. The subset of dimensions comprises the twodimensions for which the front-facing plane was not identified, but doesnot comprise the dimension for which the front-facing plane wasidentified. It is determined whether the ray intersects the box withoutperforming a test to determine whether the ray intersects the identifiedfront-facing plane at a position that is no further along the ray than aposition at which the ray intersects the back-facing plane in thedimension for which the front-facing plane was identified.

In particular, there is provided a method of determining, in a raytracing system, whether a ray intersects a three-dimensionalaxis-aligned box, wherein the box represents a volume defined by afront-facing plane and a back-facing plane for each dimension of thethree-dimensional axis-aligned box, the method comprising:

-   -   identifying which of the front-facing planes of the box        intersects the ray furthest along the ray;    -   determining whether the ray intersects the identified        front-facing plane at a position that is no further along the        ray than positions at which the ray intersects the back-facing        planes in a subset of the dimensions, wherein the subset of        dimensions comprises the two dimensions for which the        front-facing plane was not identified, but wherein the subset of        dimensions does not comprise the dimension for which the        front-facing plane was identified; and    -   determining whether the ray intersects the axis-aligned box        using the determination of whether the ray intersects the        identified front-facing plane at a position that is no further        along the ray than positions at which the ray intersects the        back-facing planes in the subset of the dimensions,    -   wherein the method determines whether the ray intersects the box        without performing a test to determine whether the ray        intersects the identified front-facing plane at a position that        is no further along the ray than a position at which the ray        intersects the back-facing plane in the dimension for which the        front-facing plane was identified.

Said steps of identifying which of the front-facing planes of the boxintersects the ray furthest along the ray and determining whether theray intersects the identified front-facing plane at a position that isno further along the ray than positions at which the ray intersects theback-facing planes in a subset of the dimensions, may be performedwithout computing intersection distances to any of the planes of thebox.

Said identifying which of the front-facing planes of the box intersectsthe ray furthest along the ray may comprise:

-   -   performing a first front-facing test to determine which of a        first front-facing plane and a second front-facing plane of the        box the ray intersects furthest along the ray; and    -   performing a second front-facing test to determine which of the        determined front-facing plane and a third front-facing plane of        the box the ray intersects furthest along the ray, thereby        identifying which of the front-facing planes of the box        intersects the ray furthest along the ray.

Said identifying which of the front-facing planes of the box intersectsthe ray furthest along the ray may comprise:

-   -   performing a first front-facing test to determine which of a        first front-facing plane and a second front-facing plane of the        box the ray intersects furthest along the ray;    -   performing a second front-facing test to determine which of the        first front-facing plane and a third front-facing plane of the        box the ray intersects furthest along the ray;    -   performing a third front-facing test to determine which of the        second front-facing plane and the third front-facing plane of        the box the ray intersects furthest along the ray; and    -   using the results of the first, second and third front-facing        tests to identify which of the front-facing planes of the box        intersects the ray furthest along the ray.

The first, second and third front-facing tests may be performed inparallel.

Said determining whether the ray intersects the identified front-facingplane at a position that is no further along the ray than positions atwhich the ray intersects the back-facing planes in the subset of thedimensions may comprise:

-   -   performing a first mixed-facing test to determine which of the        identified front-facing plane and a first back-facing plane of        the box the ray intersects furthest along the ray, wherein the        first back-facing plane of the box is a back-facing plane for a        first dimension in the subset of dimensions;    -   performing a second mixed-facing test to determine which of the        identified front-facing plane and a second back-facing plane of        the box the ray intersects furthest along the ray, wherein the        second back-facing plane of the box is a back-facing plane for a        second dimension in the subset of dimensions; and    -   using the results of the first and second mixed-facing tests to        determine whether the ray intersects the identified front-facing        plane at a position that is no further along the ray than        positions at which the ray intersects the back-facing planes in        the subset of the dimensions.

The first and second mixed-facing tests may be performed in parallel.

Said determining whether the ray intersects the identified front-facingplane at a position that is no further along the ray than positions atwhich the ray intersects the back-facing planes in the subset of thedimensions may comprise:

-   -   performing a back-facing test to determine which of a first        back-facing plane and a second back-facing plane of the box the        ray intersects least far along the ray, wherein the first        back-facing plane of the box is a back-facing plane for a first        dimension in the subset of dimensions, and the second        back-facing plane of the box is a back-facing plane for a second        dimension in the subset of dimensions;    -   performing a mixed-facing test to determine which of the        identified front-facing plane and the determined back-facing        plane of the box the ray intersects furthest along the ray; and    -   using the result of the mixed-facing test to determine whether        the ray intersects the identified front-facing plane at a        position that is no further along the ray than positions at        which the ray intersects the back-facing planes in the subset of        the dimensions.

A front-facing test, a back-facing test or a mixed-facing test todetermine which of a first plane and a second plane of the box the rayintersects furthest along the ray may comprise comparing P_(m,i)D_(j)and P_(n,j)D_(i), wherein P_(m,i) is a constant component value of thefirst plane in the i^(th) dimension, wherein P_(n,j) is a constantcomponent value of the second plane in the j^(th) dimension, whereinD_(i) and D_(j) are components of a direction vector of the ray in thei^(th) dimension and j^(th) dimension respectively, wherein ifP_(m,i)D_(j)>P_(n,j)D_(i) then it may be determined that the rayintersects with the first plane further along the ray than where itintersects with the second plane, and if P_(m,i)D_(j)<P_(n,j)D_(i) thenit may be determined that the ray intersects with the second planefurther along the ray than where it intersects with the first plane,

-   -   wherein the first plane is either: (i) the front-facing plane        for dimension i and has a component value of P_(0,i) for the        i^(th) dimension, or (ii) the back-facing plane for dimension i        and has a component value of P_(1,i) for the i^(th) dimension,        and    -   wherein the second plane is either: (i) the front-facing plane        for dimension j and has a component value of P_(0,j) for the        j^(th) dimension, or (ii) the back-facing plane for dimension j        and has a component value of P_(1,j) for the j^(th) dimension.

The method may further comprise:

-   -   storing one or more intermediate results which are determined in        said identifying which of the front-facing planes of the box        intersects the ray furthest along the ray; and    -   reading the stored one or more intermediate results for use in        said determining whether the ray intersects the identified        front-facing plane at a position that is no further along the        ray than positions at which the ray intersects the back-facing        planes in the subset of the dimensions.

The intermediate results may comprise values of P_(0,i)D_(j) andP_(0,i)D_(k) wherein the identified front-facing plane has a componentvalue of P_(0,i) for the i^(th) dimension, and wherein D_(j) and D_(k)are components of a direction vector of the ray in the j^(th) dimensionand the k^(th) dimension respectively, wherein the subset of dimensionscomprises the j^(th) and k^(th) dimensions but not the i^(th) dimension.

The method may further comprise determining whether a maximum distancecondition is satisfied, wherein the maximum distance condition may besatisfied if a maximum valid distance of the ray from the ray origin isgreater than or equal to a minimum distance from the ray origin to anyintersection of the ray with a point within the box,

-   -   wherein said determining whether the ray intersects the        axis-aligned box may further comprise using the determination of        whether the maximum distance condition is satisfied.

Said determining whether a maximum distance condition is satisfied maycomprise determining whether P_(0,i)≤D_(i)t_(max), wherein theidentified front-facing plane has a component value of P_(0,i) for thei^(th) dimension, wherein D_(i) is the component of a direction vectorof the ray in the i^(th) dimension, and wherein t_(max) is a parameterwhich defines the maximum valid distance of the ray from the ray origin.

The method may further comprise determining whether a minimum distancecondition is satisfied, wherein the minimum distance condition may besatisfied if a minimum valid distance of the ray from the ray origin isless than or equal to a maximum distance from the ray origin to anyintersection of the ray with a point within the box,

-   -   wherein said determining whether the ray intersects the        axis-aligned box may further comprise using the determination of        whether the minimum distance condition is satisfied.

Said determining whether a minimum distance condition is satisfied maycomprise: determining whether P_(1,i)≥D_(i)t_(min), P_(1,j)≥D_(j)t_(min)and P_(1,k)≥D_(k)t_(min), wherein the back-facing plane for dimension ihas a component value of P_(1,i) the back-facing plane for dimension jhas a component value of P_(1,j) the back-facing plane for dimension khas a component value of P_(1,k), wherein D_(i), D_(j) and D_(k) are thecomponents of a direction vector of the ray in the i^(th), j^(th) andk^(th) dimensions respectively, and wherein t_(min) is a parameter whichdefines the minimum valid distance of the ray from the ray origin.

Said determining whether a maximum distance condition is satisfied andsaid determining whether a minimum distance condition is satisfied maybe performed in parallel with said determining whether the rayintersects the identified front-facing plane at a position that is nofurther along the ray than positions at which the ray intersects theback-facing planes in a subset of the dimensions.

There is provided a method of determining, in a ray tracing system,whether a ray intersects a three-dimensional axis-aligned box, whereinthe box represents a volume defined by a front-facing plane and aback-facing plane for each dimension of the three-dimensionalaxis-aligned box, the method comprising:

-   -   identifying which of the back-facing planes of the box        intersects the ray least far along the ray;    -   determining whether the ray intersects the front-facing planes        in a subset of the dimensions at positions that are no further        along the ray than a position at which the ray intersects the        identified back-facing plane, wherein the subset of dimensions        comprises the two dimensions for which the back-facing plane was        not identified, but wherein the subset of dimensions does not        comprise the dimension for which the back-facing plane was        identified; and    -   determining whether the ray intersects the axis-aligned box        using the determination of whether the ray intersects the        front-facing planes in the subset of the dimensions at positions        that are no further along the ray than a position at which the        ray intersects the identified back-facing plane,    -   wherein the method determines whether the ray intersects the box        without performing a test to determine whether the ray        intersects the front-facing plane in the dimension for which the        back-facing plane was identified at a position that is no        further along the ray than a position at which the ray        intersects the identified back-facing plane.

Said identifying which of the back-facing planes of the box intersectsthe ray least far along the ray may comprise:

-   -   performing a first back-facing test to determine which of a        first back-facing plane and a second back-facing plane of the        box the ray intersects least far along the ray; and    -   performing a second back-facing test to determine which of the        determined back-facing plane and a third back-facing plane of        the box the ray intersects least far along the ray, thereby        identifying which of the back-facing planes of the box        intersects the ray least far along the ray.

Said identifying which of the back-facing planes of the box intersectsthe ray least far along the ray may comprise:

-   -   performing a first back-facing test to determine which of a        first back-facing plane and a second back-facing plane of the        box the ray intersects least far along the ray;    -   performing a second back-facing test to determine which of the        first back-facing plane and a third back-facing plane of the box        the ray intersects least far along the ray;    -   performing a third back-facing test to determine which of the        second back-facing plane and the third back-facing plane of the        box the ray intersects least far along the ray; and    -   using the results of the first, second and third back-facing        tests to identify which of the back-facing planes of the box        intersects the ray least far along the ray.

Said determining whether the ray intersects the front-facing planes inthe subset of the dimensions at positions that are no further along theray than a position at which the ray intersects the identifiedback-facing plane may comprise:

-   -   performing a first mixed-facing test to determine which of the        identified back-facing plane and a first front-facing plane of        the box the ray intersects furthest along the ray, wherein the        first front-facing plane of the box is a front-facing plane for        a first dimension in the subset of dimensions;    -   performing a second mixed-facing test to determine which of the        identified back-facing plane and a second front-facing plane of        the box the ray intersects furthest along the ray, wherein the        second front-facing plane of the box is a front-facing plane for        a second dimension in the subset of dimensions; and    -   using the results of the first and second mixed-facing tests to        determine whether the ray intersects the front-facing planes in        the subset of the dimensions at positions that are no further        along the ray than a position at which the ray intersects the        identified back-facing plane.

Said determining whether the ray intersects the front-facing planes inthe subset of the dimensions at positions that are no further along theray than a position at which the ray intersects the identifiedback-facing plane may comprise:

-   -   performing a front-facing test to determine which of a first        front-facing plane and a second front-facing plane of the box        the ray intersects furthest along the ray, wherein the first        front-facing plane of the box is a front-facing plane for a        first dimension in the subset of dimensions, and the second        front-facing plane of the box is a front-facing plane for a        second dimension in the subset of dimensions;    -   performing a mixed-facing test to determine which of the        identified back-facing plane and the determined front-facing        plane of the box the ray intersects furthest along the ray; and    -   using the result of the mixed-facing test to determine whether        the ray intersects the front-facing planes in the subset of the        dimensions at positions that are no further along the ray than a        position at which the ray intersects the identified back-facing        plane.

The method may further comprise selectively reversing the axes for thecomponents of the ray and the axis-aligned box, such that D_(i)≥0,D_(j)≥0 and D_(k)≥0, before identifying which of the front-facing planesof the box intersects the ray furthest along the ray, wherein D_(i),D_(j) and D_(k) are the components of a direction vector of the ray inthe i^(th), j^(th) and k^(th) dimensions respectively.

The method may further comprise subtracting respective components of anorigin of the ray from respective components defining the positions ofthe front-facing planes and the back-facing planes of the box.

The determination of whether the ray intersects the axis-aligned box maybe performed conservatively by rounding values determined forfront-facing planes towards −∞ and rounding values determined forback-facing planes towards +∞, such that errors introduced by roundingin the determination process cannot cause a determination that the raydoes not intersect the axis-aligned box if a perfectly accuratedetermination would have determined that the ray does intersect theaxis-aligned box.

The method may further comprise outputting an indication of a result ofthe determination of whether the ray intersects the axis-aligned box,wherein the outputted indication may be used in the ray tracing systemfor rendering an image of a 3D scene.

The axis-aligned box may be an axis-aligned bounding box which boundsgeometry to be rendered, and the axis-aligned box may correspond to anode of a hierarchical acceleration structure to be used for performingintersection testing in the ray tracing system.

The node may be part of a bottom-level acceleration structure (BLAS) forrepresenting geometry in an instance space, and the method may comprisetransforming the ray into the instance space.

There is provided an intersection testing module, for use in a raytracing system, configured to determine whether a ray intersects athree-dimensional axis-aligned box, wherein the box represents a volumedefined by a front-facing plane and a back-facing plane for eachdimension of the three-dimensional axis-aligned box, the intersectiontesting module being configured to:

-   -   identify which of the front-facing planes of the box intersects        the ray furthest along the ray;    -   determine whether the ray intersects the identified front-facing        plane at a position that is no further along the ray than        positions at which the ray intersects the back-facing planes in        a subset of the dimensions, wherein the subset of dimensions        comprises the two dimensions for which the front-facing plane        was not identified, but wherein the subset of dimensions does        not comprise the dimension for which the front-facing plane was        identified; and    -   determine whether the ray intersects the axis-aligned box using        the determination of whether the ray intersects the identified        front-facing plane at a position that is no further along the        ray than positions at which the ray intersects the back-facing        planes in the subset of the dimensions,    -   wherein the intersection testing module is configured to        determine whether the ray intersects the box without performing        a test to determine whether the ray intersects the identified        front-facing plane at a position that is no further along the        ray than a position at which the ray intersects the back-facing        plane in the dimension for which the front-facing plane was        identified.

There is provided an intersection testing module, for use in a raytracing system, configured to determine whether a ray intersects athree-dimensional axis-aligned box, wherein the box represents a volumedefined by a front-facing plane and a back-facing plane for eachdimension of the three-dimensional axis-aligned box, the intersectiontesting module being configured to:

-   -   identify which of the back-facing planes of the box intersects        the ray least far along the ray;    -   determine whether the ray intersects the front-facing planes in        a subset of the dimensions at positions that are no further        along the ray than a position at which the ray intersects the        identified back-facing plane, wherein the subset of dimensions        comprises the two dimensions for which the back-facing plane was        not identified, but wherein the subset of dimensions does not        comprise the dimension for which the back-facing plane was        identified; and    -   determine whether the ray intersects the axis-aligned box using        the determination of whether the ray intersects the front-facing        planes in a subset of the dimensions at positions that are no        further along the ray than a position at which the ray        intersects the identified back-facing plane,    -   wherein the intersection testing module is configured to        determine whether the ray intersects the box without performing        a test to determine whether the ray intersects the front-facing        plane in the dimension for which the back-facing plane was        identified at a position that is no further along the ray than a        position at which the ray intersects the identified back-facing        plane.

There is provided an intersection testing module configured to performany of the methods described herein.

The intersection testing module may be embodied in hardware on anintegrated circuit. There may be provided a method of manufacturing, atan integrated circuit manufacturing system, an intersection testingmodule. There may be provided an integrated circuit definition datasetthat, when processed in an integrated circuit manufacturing system,configures the system to manufacture an intersection testing module.There may be provided a non-transitory computer readable storage mediumhaving stored thereon a computer readable description of an intersectiontesting module that, when processed in an integrated circuitmanufacturing system, causes the integrated circuit manufacturing systemto manufacture an integrated circuit embodying an intersection testingmodule.

There may be provided an integrated circuit manufacturing systemcomprising: a non-transitory computer readable storage medium havingstored thereon a computer readable description of the intersectiontesting module; a layout processing system configured to process thecomputer readable description so as to generate a circuit layoutdescription of an integrated circuit embodying the intersection testingmodule; and an integrated circuit generation system configured tomanufacture the intersection testing module according to the circuitlayout description.

There may be provided computer program code for performing any of themethods described herein. There may be provided non-transitory computerreadable storage medium having stored thereon computer readableinstructions that, when executed at a computer system, cause thecomputer system to perform any of the methods described herein.

The above features may be combined as appropriate, as would be apparentto a skilled person, and may be combined with any of the aspects of theexamples described herein.

BRIEF DESCRIPTION OF THE DRAWINGS

Examples will now be described in detail with reference to theaccompanying drawings in which:

FIG. 1 shows a ray tracing system according to examples describedherein;

FIG. 2 a shows two rays and a box from a first viewpoint;

FIG. 2 b shows the rays and the box from a second viewpoint, wherein thesecond viewpoint is at the origin of the rays;

FIG. 3 is a flow chart for a first method of performing intersectiontesting to determine whether a ray intersects a 3D axis-aligned boxaccording to examples described herein;

FIGS. 4 a to 4 j represent tests that are performed during the firstmethod of performing intersection testing to determine whether a rayintersects a 3D axis-aligned box;

FIG. 5 a shows a ray and a box where the start of the ray is beyond thebox;

FIG. 5 b shows a ray and a box where the end of the ray is before thebox;

FIG. 5 c shows a ray and a box where the start of the ray is before thebox and the end of the ray is beyond the box;

FIG. 6 is a flow chart for a second method of performing intersectiontesting to determine whether a ray intersects a 3D axis-aligned boxaccording to examples described herein;

FIGS. 7 a to 7 j represent tests that are performed during the secondmethod of performing intersection testing to determine whether a rayintersects a 3D axis-aligned box;

FIG. 8 shows a computer system in which a ray tracing system isimplemented; and

FIG. 9 shows an integrated circuit manufacturing system for generatingan integrated circuit embodying a ray tracing system.

The accompanying drawings illustrate various examples. The skilledperson will appreciate that the illustrated element boundaries (e.g.,boxes, groups of boxes, or other shapes) in the drawings represent oneexample of the boundaries. It may be that in some examples, one elementmay be designed as multiple elements or that multiple elements may bedesigned as one element. Common reference numerals are used throughoutthe figures, where appropriate, to indicate similar features.

DETAILED DESCRIPTION

The following description is presented by way of example to enable aperson skilled in the art to make and use the invention. The presentinvention is not limited to the embodiments described herein and variousmodifications to the disclosed embodiments will be apparent to thoseskilled in the art.

Embodiments will now be described by way of example only.

Even when an acceleration structure is used, the amount of work involvedin performing intersection testing in a ray tracing system is still verylarge. For example, ray tracing may be used for rendering an image of a3D scene, where the image may have of the order of a million pixels. Aprimary ray may be traced for each sample position. In some examples,there may be one sample position for each pixel position, whilst in someother examples there may be multiple sample positions for each pixelposition (e.g. to allow for processes such as super sample anti-aliasing(SSAA) to be performed when rendering the final pixel values). When aray intersects with an object in the scene, a shader can be executedwhich may result in the emission of another ray (i.e. a “secondary ray”)into the scene. Each primary ray may result in the emission of manysecondary rays, which are all traced through the scene to determinetheir intersections. Therefore, it would not be unusual for there to betens or hundreds of millions of rays traced through a scene forrendering an image. The complexity of scenes to be rendered tends toincrease as graphics rendering technology develops, so it would not beunusual for there to be thousands of objects in a scene, each of whichmay be represented by many primitives. Furthermore, the images beingrendered may represent frames of a sequence of frames which are to berendered in real-time, e.g. for display to a user in real-time. Forexample, the user may be playing a game wherein the rendered imagesrepresent a users view of the 3D scene as the user plays the game. Inorder for the sequence of frames to appear like a continuous stream ofvideo data, many frames may be rendered per second, e.g. 24, 30 or 60frames per second to give some examples. It can therefore be appreciatedthat the work involved in performing intersection testing in a raytracing system to render scenes to be output in real-time is vast.

One way to overcome this problem, and to perform ray tracing to renderscenes to be output in real-time would be to have one or moresupercomputers to perform all of the processing. This could beconsidered to be a ‘brute force’ approach. However, as well as an aim tohave high performance (to perform ray tracing to render scenes to beoutput in real-time), there are also competing aims of reducing the size(e.g. silicon area) and power consumption of the ray tracing system. Forexample, there may be an aim to implement the ray tracing system on amobile device, such as a tablet or smartphone, for which the acceptablesize and power consumption may be much lower than for a supercomputer.As such, when designing a ray tracing system, there may be a trade-offbetween performance, power consumption and area. Depending on how thistrade-off is implemented, examples described herein may allow theperformance to be increased without a significant increase to the powerconsumption and area (compared to the prior art described above in thebackground section). Alternatively, in a different implementation of thetrade-off, examples described herein may allow the power consumptionand/or size of the ray tracing system to be decreased withoutsignificantly decreasing the performance of the ray tracing system(compared to the prior art described above in the background section).Different implementations can be designed to target different points inthe trade-off between performance, power consumption and silicon area.

As described above, testing rays for intersection with Axis AlignedBounding Boxes (AABBs), which correspond with nodes of an accelerationstructure, is an extremely frequent operation in a ray tracing system.In particular, the intersection testing of rays with bounding volumes(i.e. determining whether a ray intersects an axis-aligned box) usuallyaccounts for most of the intersection tests that are performed to renderan image of a scene using ray tracing. Therefore, any optimizations thatcan be made to the way in which the intersection tests are performed canbe very useful for optimizing the ray tracing system in terms ofreducing the latency, power consumption and physical size of the raytracing system.

In the two examples given in the background section, six tests (plusminimum and maximum distance tests) are performed to determine whether aray intersects an axis-aligned box. However, according to examplesdescribed herein, the number of tests that need to be performed todetermine whether a ray intersects an axis-aligned box is reduced. Inparticular, the number of tests is reduced to four or five (plus minimumand maximum distance tests) in the main examples described herein.Furthermore, in some situations as described below with reference toFIGS. 4 c, 4 f, 4 g and 4 j , one of these tests might not be necessary,in which case the number of tests could be further reduced to three orfour (plus minimum and maximum distance tests). This can be achieved bymaking use of the fact that, unlike a general object which may have nocorrelation between planes/faces defining the object, an AABB's planesare clearly arranged in parallel pairs, such that for each dimension theAABB has a front-facing plane and a parallel back-facing plane. For apair of parallel planes of the AABB, the front-facing (FF) plane is theone that the ray will intersect first and the back-facing (BF) plane isthe one that the ray will intersect second. If a ray intersects with thebox then it will enter the box through a front-facing plane and it willexit the box through a back-facing plane. The number of tests that needto be performed to determine whether a ray intersects an axis-alignedbox can be reduced by making use of organisation of the planes of theaxis-aligned box. Reducing the number of tests that need to be performedin order to determine whether a ray intersects an axis-aligned box canreduce the latency, size and/or power consumption of an intersectiontesting module in a ray tracing system.

FIG. 1 shows a ray tracing system 100 comprising a ray tracing unit 102and a memory 104. The ray tracing unit 102 comprises a processing module106, an intersection testing module 108 and processing logic 110. Theintersection testing module 108 comprises one or more box intersectiontesting units 112, one or more triangle intersection testing units 114and a ray adjustment unit 116. In operation the ray tracing unit 102receives geometric data defining objects within the 3D scene. The raytracing unit 102 also receives ray data defining rays that are to betested for intersection. The rays may be primary rays or secondary rays.The processing module 106 is configured to generate an accelerationstructure based on the geometric data, and to send the accelerationstructure to the memory 104 for storage therein. After the accelerationstructure has been stored in the memory 104, the intersection testingmodule 108 can retrieve nodes (comprising data defining the axis-alignedboxes corresponding to the nodes) of the acceleration structure from thememory 104 to perform intersection testing of rays against the retrievednodes. To avoid reading in the whole acceleration structure at a time,the intersection testing module 108 retrieves a subset of the boxes fromone level of the acceleration structure from memory 104 at each stage,based on the results of previous intersection tests. The boxintersection testing unit(s) 112 perform intersection tests to determinewhether or not a ray intersects each of the bounding boxes correspondingto nodes of the acceleration structure (where a miss can cull vastswathes of the hierarchical acceleration structure). If a leaf node isintersected then the triangle intersection testing unit(s) 114 performone or more triangle intersection tests to determine which object(s) (ifany) the ray intersects. The results of the intersection tests indicatewhich object in the scene a ray intersects, and the results may alsoindicate a position on the object at which the ray intersects theobject, and may also indicate a distance along the ray that theintersection occurs. The results of the intersection testing areprovided to the processing logic 110. The processing logic 110 isconfigured to process the results of the intersection testing todetermine rendered values representing the image of the 3D scene. Therendered values determined by the processing logic 110 can be passedback to the memory 104 for storage therein to represent the image of the3D scene.

FIG. 2 a illustrates two rays 202 and 214 and a box 204 from a firstviewpoint. As described above, the rays 202 and 214, r(t), can berepresented as r(t)=O+Dt , where O is a vector representing the originof the ray and D is the direction vector of the ray, where O=(O_(x),O_(y), O_(z)) and D=(D_(x),D_(y),D_(z)). The x, y and z basis vectors ofthe coordinate system are shown in FIGS. 2 a and 2 b . In this example,both of the rays 202 and 214 have the same origin and the origin of thecoordinate system is at the origin of the rays. This can be achieved bytranslating the positions of the ray origins and the box by subtractingthe ray origin. The box 204 is an axis-aligned box with respect to thex, y and z basis vectors of the coordinate system. The coordinate systemcould be a world space coordinate system of a scene being rendered, orthe coordinate system could be an instance space coordinate system of aninstance of a set of geometry within a scene being rendered. The corner206 of the box 204 is ata position (x_(min), y_(min), z_(min)) and theopposite corner 208 of the box is ata position (x_(max), y_(max),z_(max)). The box 204 represents a volume defined by a front-facingplane and a back-facing plane for each dimension of thethree-dimensional axis-aligned box. In particular, for the x dimensionthere is: (i) a front-facing plane (including corner points 206, 216,218 and 222) which has a normal which is parallel to the x-axis andwhich points towards negative values of x, wherein any point on thefront-facing plane for the x dimension has an x component value ofx_(min); and (ii) a back-facing plane (including corner points 208, 220,224 and 226) which has a normal which is parallel to the x-axis andwhich points towards positive values of x, wherein any point on theback-facing plane for the x dimension has a x component value ofx_(max). For the y dimension there is: (i) a front-facing plane(including corner points 206, 222, 224 and 226) which has a normal whichis parallel to the y-axis and which points towards negative values of y,wherein any point on the front-facing plane for the y dimension has a ycomponent value of y_(min); and (ii) a back-facing plane (includingcorner points 208, 216, 218 and 220) which has a normal which isparallel to the y-axis and which points towards positive values of y,wherein any point on the back-facing plane for the y dimension has a ycomponent value of y_(max). For the z dimension there is: (i) afront-facing plane (including corner points 206, 218, 220 and 224) whichhas a normal which is parallel to the z-axis and which points towardsnegative values of z, wherein any point on the front-facing plane forthe z dimension has a z component value of z_(min); and (ii) aback-facing plane (including corner points 208, 216, 222 and 226) whichhas a normal which is parallel to the z-axis and which points towardspositive values of z, wherein any point on the back-facing plane for thez dimension has a z component value of z_(max). In the example shown inFIG. 2 a , the rays 202 and 214 and the box 204 are all in the positiveoctant of the coordinate system, i.e. the direction vectors of rays 202and 214 have positive values for all of their component values, and allof x_(min), y_(min), z_(min), x_(max), y_(max) and z_(max) are positive.

FIG. 2 b shows the rays 202 and 214 and the box 204 from a secondviewpoint, wherein the second viewpoint is at the origin of the rays.Since the viewpoint of FIG. 2 b is the origin of the rays 202 and 214,the rays just appear as points. The x, y and z axes are shown in FIG. 2b . The corners of the box 204 are labelled as 206, 208, 216, 218, 220,222, 224 and 226 consistently in both FIGS. 2 a and 2 b to aid theunderstanding of how the box 204 is viewed in the two figures.

The ray 202 intersects the box 204. In particular, the ray 202intersects planes of the box at positions 210 and 212. In FIG. 2 b , theintersection points 210 and 212 are at the same projected position asthe ray 202. The ray 202 enters the box 204 at position 210 which is onthe front-facing plane of the box 204 for the z dimension, which has aconstant z component value of z_(min). The ray 202 exits the box 204 atposition 212 which is on the back-facing plane of the box 204 for theydimension, which has a constant y component value of y_(max). The ray214 does not intersect the box 204.

FIG. 3 is a flow chart for a method of performing intersection testingto determine whether the ray 202 intersects the 3D axis-aligned box 204.Although the description below refers to testing whether the ray 202intersects the box 204, the same method can be applied for testingwhether the ray 214 intersects the box 204.

In step S302 data defining the ray 202 and the box 204 are obtained atthe intersection testing module 108. In particular, data defining thecomponents of the ray origin and the ray direction are obtained. Thedata defining the ray origin may be the three components of the rayorigin position, O_(x), O_(y) and O_(z). The data defining the raydirection may comprise the three components of the ray direction, D_(x),D_(y) and D_(z). Alternatively, some different values defining the raydirection may have been pre-computed and stored in a store, such that instep S302 the pre-computed values may be read. For example, three valuesmay be read to define the ray direction data, and these three values maybe

$\frac{D_{x}}{D_{z}},{\frac{D_{y}}{D_{z}}{and}{\frac{1}{D_{z}}.}}$In other examples, different pre-computed values may be read to definethe ray direction, e.g. values of

$\frac{D_{z}}{D_{x}},\frac{D_{z}}{D_{y}}$and D_(z) may be read, or values of

$\frac{D_{x}}{D_{z}},\frac{D_{y}}{D_{z}}$and sgn(D_(z)) may be read. It is noted that, for a value f, sgn(f)=+1if f is positive, and sgn(f)=−1 if f is negative. In other examples,other values may be pre-computed and read in order to define the raydirection. The data defining the box may be data defining the positionsof the planes representing the box, e.g. the component values which areconstant for each of the front-facing plane and the back-facing plane ineach of the three dimensions.

In step S304, the intersection testing module 108 subtracts respectivecomponents of the origin of the ray from respective components definingthe positions of the front-facing planes and the back-facing planes ofthe box. Step S304 can be described as performing a translation on theray 202 and the box 204 so that the origin of the coordinate system isat the origin of the ray 202. From this point on in the method describedwith reference to FIG. 3 , the origin of the ray is at the origin of thecoordinate system, i.e. at a position (0,0,0).

In step S306 the axes for the components of the ray and the box areselectively reversed by the intersection testing module 108 (e.g. by theray adjustment unit 116), such that D_(x)≥0, D_(y)≥0 and D_(z)≤0. In themethod described with reference to FIG. 3 , the selective reversing ofzero, one or more of the axes is performed so that the ray direction isinto the octant with positive D_(x), D_(y) and D_(z). The “reversing” ofthe axes, may be referred to as “reflecting”, “inverting” or “negating”,and may involve changing the sign of all of the component values in thedimension along the axis in question. The data defining the raycomprises the ray origin and the ray direction, and the data definingthe box comprises the values representing the positions of the planes ofthe in each dimension. It is noted that reversing an odd number of theaxes reverses the orientation of the geometry. In some examples, stepS306 may also include the intersection testing module 108 (e.g. by theray adjustment unit 116) selectively permuting (i.e. rearranging) theaxes. A permutation of the axes comprises either a rotation of threeaxes, a transposition of two axes or the identity (i.e. not changing theaxes). For example, a permutation of the axes may be performed so thatthe major component of the ray direction is D_(z) (i.e. ensuring that|D_(z)|≥|D_(x)| and |D_(z)|≥|D_(y)|). However, a permutation is notnecessary in the example described with reference to FIG. 3 . At the endof step S306, the intersection testing module 108 has determined thevalues of x_(min), y_(min), z_(min), x_(max), y_(max) and z_(max). Thevalues of x_(min), y_(min), z_(min), x_(max), y_(max) and z_(max)represent displacements of the front-facing and back-facing planes ofthe axis aligned box in each dimension relative to the ray origin.

FIGS. 2 a and 2 b show the ray 202 and the box 204 after the translationand the selective reversing of the axes of the ray and the box have beenperformed in steps S304 and S306, such that the origin of the coordinatesystem is at the origin of the ray, and such that D_(x)≥0, D_(y)≥0 andD_(z)≥0.

Unlike a general object which may have no correlation betweenplanes/faces defining the object, the planes defining the faces of anaxis-aligned bounding box (AABB) are arranged in parallel pairs, suchthat for each dimension the AABB has a front-facing plane and a parallelback-facing plane. As described above, the axes are selectively reversedsuch that the ray direction vector points into the octant of thespace-coordinate system which has positive values for x, y and z, i.e.D_(x)≥0, D_(y)≥0 and D_(z)>0. Therefore, the front-facing plane for anaxis has a lower constant component value along that axis than theback-facing plane for the axis. For a pair of parallel planes of theAABB, the front-facing (FF) plane is the one that the ray will intersectfirst (when looking along the direction of the ray from −∞) and theback-facing (BF) plane is the one that the ray will intersect second(when looking along the direction of the ray from −∞). If a rayintersects with the box 204 (for which all of x_(min), y_(min), z_(min),x_(max), y_(max) and z_(max) are positive) then it will enter the boxthrough a front-facing plane and it will exit the box through aback-facing plane. This generalises so that if a box is placed behind aray origin (such that intersection may occur for negative t), thefront-facing plane is intersected by the ray at the lower (mostnegative) value oft and the back-facing plane is intersected by the rayat the higher (least negative) value of t. It is also noted that if theray points parallel to any pair of planes (i.e. if at least one ofD_(x), D_(y) and D_(z) is zero), then it will intersect, at most, one ofthe planes of the pair of planes, whereas if a ray is not parallel to apair of planes then there are unique entry and exit points of the(infinite) volume bounded by the front- and back-facing planes of thepair of planes respectively.

In step S308 the intersection testing module 108 (specifically the oneor more box intersection testing units 112) identifies which of thefront-facing planes of the box intersects the ray furthest along theray. As described above, for each dimension the box 204 has afront-facing plane and a back-facing plane. A ray will intersect thefront-facing plane for a dimension before it intersects the back-facingplane for the dimension (unless the ray is parallel to the axis, whichis described in more detail below). Because of the selective reversingof the axes in step S306, such that the ray is directed into thepositive octant of the space coordinate system defined by the x, y and zaxes, the front-facing plane for a dimension will have the minimumcomponent value for that dimension (e.g. x_(min), y_(min) or z_(min)),and the back-facing plane for a dimension will have the maximumcomponent value for that dimension (e.g. x_(max), y_(max) or z_(max)).If the ray origin lies outside the box and if the ray enters and exits abox then the ray enters the box through a front-facing plane, and theray exits the box through a back-facing plane. In particular, if a rayenters and exits a box then the ray enters the box through thefront-facing plane which (out of the three front-facing planes of thebox) intersects the ray furthest along the ray, and the ray exits thebox through the back-facing plane which (out of the three back-facingplanes) intersects the ray least far along the ray. In the case of atie, the ray enters (or exits) the box on multiple front-facing (orback-facing) planes, either on a corner (if all faces tie) or an edge(if two faces tie). The phrase “furthest along the ray” is to beunderstood here as meaning “at a point with the greatest t value” (inthe ray equation r(t)=O+Dt) and the phrase “least far along the ray” isto be understood here as meaning “at a point with the lowest t value”(in the ray equation r(t)=O+Dt). Therefore, in the examples describedherein, the phrases “furthest along” and “least far along” are referringto the ray direction vector, rather than meaning “furthest from the rayorigin” or “least far from the ray origin”.

Two example approaches for identifying which of the front-facing planesof the box intersects the ray furthest along the ray in step S308 aredescribed in detail below. In the examples described below we refer toi, j and k dimensions which can correspond to the x, y and z dimensionsof the coordinate system in any order or arrangement.

A First Approach for Identifying Which of the Front-Facing Planes of theBox Intersects the Ray Furthest Along the Ray in Step S308

In the first approach for performing step S308 described herein, stepS308 comprises: (i) performing a first front-facing test to determinewhich of a first front-facing plane and a second front-facing plane ofthe box the ray intersects furthest along the ray, and (ii) performing asecond front-facing test to determine which of the determinedfront-facing plane and a third front-facing plane of the box the rayintersects furthest along the ray, thereby identifying which of thefront-facing planes of the box intersects the ray furthest along theray. In this approach, two tests are performed sequentially. The secondtest uses the result of the first test.

As described above, a point on the ray 202 is given by O+Dt where O isthe ray origin, D is the ray direction and t represents a distance alongthe ray from the origin. Due to step S304, the components of theremapped ray origin are all zero. The components of the ray directionvector are D_(i), D_(j) and D_(k), where, as described above, i, j and kcorrespond to the x, y and z dimensions in any order. A ray willintersect a position Dt₁ before it intersects a position Dt₂ if t₁<t₂.The ray will intersect the front-facing plane for dimension i when theparameter t has a value such that D_(i)t=F_(i), where F_(i) is thecomponent value for the i^(th) dimension which is constant on thatplane; and the ray will intersect the front-facing plane for dimension jwhen the parameter t has a value such that D_(j)t=F_(j), where F_(j) isthe component value for the j^(th) dimension which is constant on thatplane. Depending on how the i^(th) and j^(th) dimensions respectivelycorrespond to the x, y or z dimensions, the values of F_(i) and F_(j)will each be one of x_(min), y_(min) and z_(min). Therefore, the raywill intersect the front-facing plane for dimension i before itintersects the front-facing plane for dimension j if

$\frac{F_{i}}{D_{i}} < {\frac{F_{j}}{D_{j}}.}$However, performing division operations is typically more expensive (interms of latency, silicon area and/or power consumption) than performingmultiply operations, so rather than performing a comparison to comparevalues of

${\frac{F_{i}}{D_{i}}{and}\frac{F_{j}}{D_{j}}},$the method can instead perform a comparison to compare values ofF_(i)D_(j) and F_(j)D_(i). In this way, the operations arecross-multiplied to avoid needing to perform a divide operation in thecomparison. If F_(i)D_(j)<F_(j)D_(i) then it is determined that the rayintersects with front-facing plane j further along the ray than where itintersects with front-facing plane i, and if F_(i)D_(j)>F_(j)D_(i) thenit is determined that the ray intersects with front-facing plane ifurther along the ray than where it intersects with front-facing planej. This comparison involves performing two multiply operations and acomparison of the results of the two multiply operations. Note that ifF_(i)D_(j)=F_(j)D_(i) then, in effect, the ray intersects the edge wherethe planes meet. In this case it is equally valid to choose either planeas the “further”, and the choice does not affect the validity of thetesting process, so either one of the front-facing planes can be chosen.Multiply and compare operations are not costly to implement in hardwarerelative to division or to subtract operations, e.g. they can beimplemented in hardware (e.g. fixed-function circuitry) with a smallsilicon area. Division and subtraction operations to produce floatingpoint results are relatively expensive (e.g. in terms of silicon area)to implement in hardware. Therefore, implementing multiply and compareoperations to determine whether F_(i)D_(j)>F_(j)D_(i) is cheaper (e.g.in terms of silicon area) to implement in hardware than implementingdivision and compare operations to determine whether

$\frac{F_{i}}{D_{i}} > \frac{F_{j}}{D_{j}}$or implementing multiply and subtract operations to determine whetherF_(i)D_(j)−F_(j)D_(i)>0. It is noted that the coordinate system hasalready been adjusted so that the D_(i) and D_(j) values are ≥0 (andthat special cases for D=0 will be covered later), so that thecomparison operators “<” and/or “>” do not need to be changed toaccommodate for the possibility of negative values of D_(i) and D_(j).

FIGS. 4 a and 4 b illustrate the first front-facing test to determinewhether F_(i)D_(j)>F_(j)D_(i). In particular, FIGS. 4 a and 4 b show anaxis-aligned box 402 with three front-facing planes and threeback-facing planes, as viewed from the viewpoint of the origin of a ray(similar to FIG. 2 b ). The edge 404 defines a line (which is shown as adashed line) which is where the front-facing planes for the i^(th) andj^(th) dimensions intersect. Following the first front-facing test todetermine whether F_(i)D_(j)>F_(j)D_(i) it is known which side of theline defined by the edge 404 the ray passes on. Therefore, thiscomparison can be considered to be an edge test on the edge 404. Thiscomparison can also be considered to be a test of which of the twofront-facing planes (for dimensions i and j) intersects the ray furthestalong the ray. The dotted region to one side of the line defined by theedge 404 represents a region which it is known that the ray does notintersect due to the determination of whether F_(i)D_(j)>F_(j)D_(i). Inother words, the determination of whether F_(i)D_(j)>F_(j)D_(i)determines that the ray passes somewhere in the undotted region to theother side of the line defined by the edge 404. FIG. 4 a shows thesituation in which the ray passes to the right of the line defined bythe edge 404, i.e. F_(i)D_(j)>F_(j)D_(i) such that the front-facingplane for dimension i intersects the ray further along the ray thanwhere the front-facing plane for dimension j intersects the ray. Incontrast, FIG. 4 b shows the situation in which the ray passes to theleft of the line defined by the edge 404, i.e. F_(i)D_(j)<F_(j)D_(i)such that the front-facing plane for dimension j intersects the rayfurther along the ray than where the front-facing plane for dimension iintersects the ray. As mentioned above, if F_(i)D_(j)=F_(j)D_(i) theneither of the front-facing planes for dimensions i and j can be chosen.For example, if the ray intersects the line defined by the edge 404 thenit can be considered to be in both the undotted regions shown in FIGS. 4a and 4 b.

In the second front-facing test, the front-facing plane which wasdetermined to intersect the ray furthest along the ray in the firstfront-facing test is tested against the remaining front-facing plane todetermine which of the front-facing planes of the box intersects the rayfurthest along the ray. For example, if it was determined that thefront-facing plane for dimension i intersects the ray further along theray than where the front-facing plane for dimension j intersects the ray(i.e. in the situation shown in FIG. 4 a ) then the second front-facingtest comprises determining whether F_(i)D_(k)>F_(k)D_(i), as illustratedin FIGS. 4 c and 4 d . The edge 406 defines a line (which is shown as adashed line) which is where the front-facing planes for the i^(th) andk^(th) dimensions intersect. Following the second front-facing test todetermine whether F_(i)D_(k)>F_(k)D_(i) it is known which side of theline defined by the edge 406 the ray passes on. Therefore, thiscomparison can be considered to be an edge test on the edge 406. Thiscomparison can also be considered to be a test of which of the twofront-facing planes (for dimensions i and k) intersects the ray furthestalong the ray. The dotted region to one side of the line defined by theedge 406 represents a region which it is known that the ray does notintersect due to the determination of whether F_(i)D_(k)>F_(k)D_(i). Inother words, the determination of whether F_(i)D_(k)>F_(k)D_(i)determines that the ray passes somewhere in the undotted region to theother side of the line defined by the edge 406. FIG. 4 c shows thesituation in which the ray passes below the line defined by the edge406, i.e. F_(i)D_(k)<F_(k)D_(i) such that the front-facing plane fordimension k intersects the ray further along the ray than where thefront-facing plane for dimension i intersects the ray. Therefore, in thesituation shown in FIG. 4 c , step S308 identifies the front-facingplane for dimension k. In contrast, FIG. 4 d shows the situation inwhich the ray passes above the line defined by the edge 406, i.e.F_(i)D_(k)>F_(k)D_(i) such that the front-facing plane for dimension iintersects the ray further along the ray than where the front-facingplane for dimension k intersects the ray. Therefore, in the situationshown in FIG. 4 d , step S308 identifies the front-facing plane fordimension i. As mentioned above, if F_(i)D_(k)=F_(k)D_(i) then either ofthe front-facing planes for dimensions i and k can be chosen.

If it was determined that the front-facing plane for dimension jintersects the ray further along the ray than where the front-facingplane for dimension i intersects the ray (i.e. in the situation shown inFIG. 4 b) then the second front-facing test comprises determiningwhether F_(j)D_(k)>F_(k)D_(j), as illustrated in FIGS. 4 e and 4 f . Theedge 408 defines a line (which is shown as a dashed line) which is wherethe front-facing planes for the j^(th) and k^(th) dimensions intersect.Following the second front-facing test to determine whetherF_(j)D_(k)>F_(k)D_(j) it is known which side of the line defined by theedge 408 the ray passes on. Therefore, this comparison can be consideredto be an edge test on the edge 408. This comparison can also beconsidered to be a test of which of the two front-facing planes (fordimensions j and k) intersects the ray furthest along the ray. Thedotted region to one side of the line defined by the edge 408 representsa region which it is known that the ray does not intersect due to thedetermination of whether F_(j)D_(k)>F_(k)D_(j). In other words, thedetermination of whether F_(j)D_(k)>F_(k)D_(j) determines that the raypasses somewhere in the undotted region to the other side of the linedefined by the edge 408. FIG. 4 e shows the situation in which the raypasses above the line defined by the edge 408, i.e.F_(j)D_(k)>F_(k)D_(j) such that the front-facing plane for dimension jintersects the ray further along the ray than where the front-facingplane for dimension k intersects the ray. Therefore, in the situationshown in FIG. 4 e , step S308 identifies the front-facing plane fordimension j. In contrast, FIG. 4 f shows the situation in which the raypasses below the line defined by the edge 408, i.e.F_(j)D_(k)<F_(k)D_(j) such that the front-facing plane for dimension kintersects the ray further along the ray than where the front-facingplane for dimension j intersects the ray. Therefore, in the situationshown in FIG. 4 f , step S308 identifies the front-facing plane fordimension k. As mentioned above, if F_(j)D_(k)=F_(k)D_(j) then either ofthe front-facing planes for dimensions j and k can be chosen.

A Second Approach for Identifying Which of the Front-Facing Planes ofthe Box Intersects the Ray Furthest Along the Ray in Step S308

In the second approach for performing step S308 described herein, stepS308 comprises: (i) performing a first front-facing test to determinewhich of a first front-facing plane and a second front-facing plane ofthe box the ray intersects furthest along the ray; (ii) performing asecond front-facing test to determine which of the first front-facingplane and a third front-facing plane of the box the ray intersectsfurthest along the ray; and (iii) performing a third front-facing testto determine which of the second front-facing plane and the thirdfront-facing plane of the box the ray intersects furthest along the ray.The results of the first, second and third front-facing tests are usedto identify which of the front-facing planes of the box intersects theray furthest along the ray. In this second approach, the first, secondand third front-facing tests are performed independently of each other(i.e. they do not require results from one another), and so these threetests may be performed in parallel.

This second approach can be considered to be performing threefront-facing tests to test which side of each of the lines defined bythe three edges 404, 406 and 408 the ray passes on. For example, thefirst front-facing test may determine whether F_(i)D_(j)>F_(j)D_(i). IfF_(i)D_(j)>F_(j)D_(i) then the front-facing plane for dimension iintersects the ray further along the ray than where the front-facingplane for dimension j intersects the ray (e.g. the ray passes on theright of the line defined by edge 404); whereas if F_(i)D_(j)<F_(j)D_(i)then the front-facing plane for dimension j intersects the ray furtheralong the ray than where the front-facing plane for dimension iintersects the ray (e.g. the ray passes on the left of the line definedby edge 404). The second front-facing test may determine whetherF_(i)D_(k)>F_(k)D_(i). If F_(i)D_(k)>F_(k)D_(i) then the front-facingplane for dimension i intersects the ray further along the ray thanwhere the front-facing plane for dimension k intersects the ray (e.g.the ray passes above the line defined by edge 406); whereas ifF_(i)D_(k)<F_(k)D_(i) then the front-facing plane for dimension kintersects the ray further along the ray than where the front-facingplane for dimension i intersects the ray (e.g. the ray passes below theline defined by edge 406). The third front-facing test may determinewhether F_(j)D_(k)>F_(k)D_(j). If F_(j)D_(k)>F_(k)D_(j) then thefront-facing plane for dimension j intersects the ray further along theray than where the front-facing plane for dimension k intersects the ray(e.g. the ray passes above the line defined by edge 408); whereas ifF_(j)D_(k)<F_(k)D_(j) then the front-facing plane for dimension kintersects the ray further along the ray than where the front-facingplane for dimension j intersects the ray (e.g. the ray passes below theline defined by edge 408). As described above, the results of the first,second and third front-facing tests can be used to identify which of thefront-facing planes of the box intersects the ray furthest along theray.

In the first approach for performing step S308 described above, twofront-facing tests are performed in series; whereas in the secondapproach for performing step S308 described above, three front-facingtests are performed, and these three tests may be performed in parallel.In some implementations, it may be considered beneficial to reduce thenumber of tests that need to be performed, so the first approach forperforming step S308 may be used because this involves performing twofront-facing tests rather than three. However, in some otherimplementations, it may be considered beneficial to shorten theprocessing pipeline (e.g. to reduce latency), so the second approach forperforming step S308 may be used because the front-facing tests in stepS308 can all be performed in parallel together, rather than performingthe tests in series.

At the end of step S308, the intersection testing module 108 hasidentified which of the front-facing planes of the box the rayintersects furthest along the ray (e.g. as illustrated in FIGS. 4 c to 4f ).

In step S310 the intersection testing module 108 (specifically the oneor more box intersection testing units 112) determines whether the ray202 intersects the identified front-facing plane at a position that isno further along the ray than positions at which the ray intersects theback-facing planes in a subset of the dimensions. The term “subset” asused in this context refers to a proper subset. In other words, thesubset of the dimensions does not include all of the dimensions. Inparticular, the subset of dimensions comprises the two dimensions forwhich the front-facing plane was not identified, but the subset ofdimensions does not comprise the dimension for which the front-facingplane was identified. This is because the inventors have realised thatfor each dimension, a ray will intersect the front-facing plane of anaxis-aligned box for that dimension before it intersects the back-facingplane of the axis-aligned box for that dimension. This is partly becausethe front-facing plane and back-facing plane of an axis-aligned box fora particular dimension are parallel. So without performing any tests,the intersection testing module 108 can know that the ray 202 intersectsthe identified front-facing plane before it intersects the back-facingplane in the dimension for which the front-facing plane was identified.This realisation allows the number of tests that need to be performed todetermine whether a ray intersects an axis-aligned box to be reduced.Two example approaches for determining whether the ray intersects theidentified front-facing plane before it intersects the back-facingplanes in the subset of the dimensions in step S310 are described indetail below.

A First Approach for Determining Whether the Ray Intersects theIdentified Front-Facing Plane at a Position that is no Further Along theRay than Positions at Which the Ray Intersects the Back-Facing Planes inthe Subset of the Dimensions in Step S310

In the first approach for performing step S310 described herein, stepS310 comprises: (i) performing a first mixed-facing test to determinewhich of the identified front-facing plane and a first back-facing planeof the box the ray intersects furthest along the ray, wherein the firstback-facing plane of the box is a back-facing plane for a firstdimension in the subset of dimensions; (ii) performing a secondmixed-facing test to determine which of the identified front-facingplane and a second back-facing plane of the box the ray intersectsfurthest along the ray, wherein the second back-facing plane of the boxis a back-facing plane for a second dimension in the subset ofdimensions; and (iii) using the results of the first and secondmixed-facing tests to determine whether the ray intersects theidentified front-facing plane at a position that is no further along theray than positions at which the ray intersects the back-facing planes inthe subset of the dimensions. In this approach, the first and secondmixed-facing tests do not depend upon the results of one another so theymay be performed in parallel. It is noted that the term “front-facingtest” is used herein to refer to a test to compare the distances atwhich two front-facing planes intersect the ray; the term “back-facingtest” is used herein to refer to a test to compare the distances atwhich two back-facing planes intersect the ray; and the term“mixed-facing test” is used herein to refer to a test to compare thedistances at which a front-facing plane and a back-facing planeintersect the ray.

FIGS. 4 g to 4 j illustrate the tests that are performed in step S310 indifferent situations. For example, FIGS. 4 g and 4 j follow on from thesituations shown in FIGS. 4 c and 4 f respectively in which thefront-facing plane for dimension k was identified in step S308. In thesetwo cases the first and second mixed-facing tests determine which sideof the lines defined by the two edges 410 and 412 the ray passes on. Forexample, the first mixed-facing test may determine whetherF_(k)D_(i)>B_(i)D_(k), where F_(k) is the component value for the k^(th)dimension which is constant on that front-facing plane for dimension k,and B_(i) is the component value for the i^(th) dimension which isconstant on the back-facing plane for dimension i. This test correspondsto testing which side of the line defined by the edge 410 the ray passeson. If F_(k)D_(i)>B_(i)D_(k) then the front-facing plane for dimension kintersects the ray further along the ray than where the back-facingplane for dimension i intersects the ray (e.g. the ray passes below theline defined by edge 410) such that the ray will miss the box; whereasif F_(k)D_(i)≤B_(i)D_(k) then the front-facing plane for dimension kintersects the ray no further along the ray than where the back-facingplane for dimension i intersects the ray (e.g. the ray passes above theline defined by edge 410) such that the ray might intersect the box. Thesecond mixed-facing test may determine whether F_(k)D_(j)>B_(j)D_(k),where B_(j) is the component value for the j^(th) dimension which isconstant on the back-facing plane for dimension j. This test correspondsto testing which side of the line defined by the edge 412 the ray passeson. If F_(k)D_(j)>B_(j)D_(k) then the front-facing plane for dimension kintersects the ray further along the ray than where the back-facingplane for dimension j intersects the ray (e.g. the ray passes below theline defined by edge 412) such that the ray will miss the box; whereasif F_(k)D_(j)≤B_(j)D_(k) then the front-facing plane for dimension kintersects the ray no further along the ray than where the back-facingplane for dimension j intersects the ray (e.g. the ray passes above theline defined by edge 412) such that the ray might intersect the box. Itis noted that the values of one or both of F_(k)D_(j) and F_(k)D_(i) mayhave been calculated in step S308. These values may be recalculated instep S310 or they may be saved (e.g. in registers) during step S308 sothat they can be reused in step S310 without needing to recalculatethem.

For the ray to intersect the box, the ray must intersect the identifiedfront-facing plane at a point that is no further from the ray originthan the points at which the ray intersects the back-facing planes ofthe box. In examples described herein, a test does not need to beperformed to determine whether the ray intersects the identifiedfront-facing plane before it intersects the back-facing plane for thedimension for which the front-facing plane was identified. In someexamples (e.g. as described in the preceding paragraph), both the firstmixed-facing test and the second mixed-facing test must pass for a hitto be determined for the ray with respect to the box, i.e. two tests areperformed to determine that the ray does not intersect the respectiveback-facing planes for the two dimensions in the subset of dimensionsbefore the ray intersects the identified front-facing plane. However, insome other examples, in some situations one of the mixed-facing tests isnot required to be performed. For example, in the situation shown inFIG. 4 j , only one mixed-facing test is required in step S310 (i.e. totest which side of the line defined by the edge 410 the ray passes on).If the box intersection testing unit(s) 112 can determine that thegeometry of the box is such that only one test needs to be performed(e.g. in the situation shown in FIG. 4 j but not in the situation shownin FIG. 4 g ) then only one test needs to be performed in step S310.

As another example, FIG. 4 h follows on from the situation shown in FIG.4 d in which the front-facing plane for dimension i was identified instep S308. In this case the first and second mixed-facing testsdetermine which side of the lines defined by the two edges 414 and 416the ray passes on. For example, the first mixed-facing test maydetermine whether F_(i)D_(j)>B_(j)D_(i), where F_(i) is the componentvalue for the i^(th) dimension which is constant on that front-facingplane for dimension i, and B_(j) is the component value for the j^(th)dimension which is constant on the back-facing plane for dimension j.This test corresponds to testing which side of the line defined by theedge 416 the ray passes on. If F_(i)D_(j)>B_(j)D_(i) then thefront-facing plane for dimension i intersects the ray further along theray than where the back-facing plane for dimension j intersects the ray(e.g. the ray passes to the right of the line defined by edge 416) suchthat the ray will miss the box; whereas if F_(i)D_(j)≤B_(j)D_(i) thenthe front-facing plane for dimension i intersects the ray no furtheralong the ray than where the back-facing plane for dimension jintersects the ray (e.g. the ray passes to the left of the line definedby edge 416) such that the ray might intersect the box. The secondmixed-facing test may determine whether F_(i)D_(k)>B_(k)D_(i), whereB_(k) is the component value for the k^(th) dimension which is constanton the back-facing plane for dimension k. This test corresponds totesting which side of the line defined by the edge 414 the ray passeson. If F_(i)D_(k)>B_(k)D_(i) then the front-facing plane for dimension iintersects the ray further along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes above theline defined by edge 414) such that the ray will miss the box; whereasif F_(i)D_(k)≤B_(k)D_(i) then the front-facing plane for dimension iintersects the ray no further along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes below theline defined by edge 414) such that the ray might intersect the box. Itis noted that the values of one or both of F_(i)D_(j) and F_(i)D_(k) mayhave been calculated in step S308. These values may be recalculated instep S310 or they may be saved (e.g. in registers) during step S308 sothat they can be reused in step S310 without needing to recalculatethem.

As another example, FIG. 4 i follows on from the situation shown in FIG.4 e in which the front-facing plane for dimension j was identified instep S308. In this case the first and second mixed-facing testsdetermine which side of the lines defined by the two edges 418 and 420the ray passes on. For example, the first mixed-facing test maydetermine whether F_(j)D_(k)>B_(k)D_(j), where F_(j) is the componentvalue for the j^(th) dimension which is constant on that front-facingplane for dimension j. This test corresponds to testing which side ofthe line defined by the edge 418 the ray passes on. IfF_(j)D_(k)>B_(k)D_(j) then the front-facing plane for dimension jintersects the ray further along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes above theline defined by edge 418) such that the ray will miss the box; whereasif F_(j)D_(k)≤B_(k)D_(j) then the front-facing plane for dimension jintersects the ray no further along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes below theline defined by edge 418) such that the ray might intersect the box. Thesecond mixed-facing test may determine whether F_(j)D_(i)>B_(i)D_(j).This test corresponds to testing which side of the line defined by theedge 420 the ray passes on. If F_(j)D_(i)>B_(i)D_(j) then thefront-facing plane for dimension j intersects the ray further along theray than where the back-facing plane for dimension i intersects the ray(e.g. the ray passes to the left of the line defined by edge 420) suchthat the ray will miss the box; whereas if F_(j)D_(i)≤B_(i)D_(j) thenthe front-facing plane for dimension j intersects the ray no furtheralong the ray than where the back-facing plane for dimension iintersects the ray (e.g. the ray passes to the right of the line definedby edge 420) such that the ray might intersect the box. It is noted thatthe values of one or both of F_(j)D_(k) and F_(j)D_(i) may have beencalculated in step S308. These values may be recalculated in step S310or they may be saved (e.g. in registers) during step S308 so that theycan be reused in step S310 without needing to recalculate them.

A Second Approach for Determining Whether the Ray Intersects theIdentified Front-Facing Plane at a Position that is no Further Along theRay than Positions at Which the Ray Intersects the Back-Facing Planes inthe Subset of the Dimensions in Step S310

In the second approach for performing step S310 described herein, stepS310 comprises: (i) performing a back-facing test to determine which ofa first back-facing plane and a second back-facing plane of the box theray intersects least far along the ray, wherein the first and secondback-facing planes of the box are back-facing planes for first andsecond dimensions in the subset of dimensions; (ii) performing amixed-facing test to determine which of the identified front-facingplane and the determined back-facing plane of the box the ray intersectsfurthest along the ray; and (iii) using the result of the mixed-facingtest to determine whether the ray intersects the identified front-facingplane at a position that is no further along the ray than positions atwhich the ray intersects the back-facing planes in the subset of thedimensions.

In other words, in this approach, the closest back-facing plane for theray is determined, and then the intersection testing module 108determines whether the furthest front-facing plane (i.e. the identifiedfront-facing plane) is further along the ray than the closestback-facing plane. If it is, then the ray misses the box.

For example, in FIGS. 4 c and 4 f the front-facing plane for dimension kwas identified in step S308. In these two cases the back-facing testdetermines which of the back-facing planes for dimensions i and jintersects the ray least far along the ray. The back-facing test maydetermine whether B_(i)D_(j)>B_(j)D_(i). If B_(i)D_(j)>B_(j)D_(i) thenthe back-facing plane for dimension j intersects the ray less far alongthe ray than where the back-facing plane for dimension i intersects theray; whereas if B_(i)D_(j)<B_(j)D_(i) then the back-facing plane fordimension i intersects the ray less far along the ray than where theback-facing plane for dimension j intersects the ray. IfB_(i)D_(j)=B_(j)D_(i) then either of the back-facing planes fordimensions i or j can be chosen. The mixed-facing test may determinewhether F_(k)D_(near)>B_(near)D_(k), where the dimension (either i or jin this case) for which the back-facing plane is determined to be leastfar along the ray is denoted “near”. If F_(k)D_(near)>B_(near)D_(k) thenthe front-facing plane for dimension k intersects the ray further alongthe ray than where the determined back-facing plane intersects the ray,such that the ray will miss the box; whereas ifF_(k)D_(near)≤B_(near)D_(k) then the front-facing plane for dimension kintersects the ray no further along the ray than where the determinedback-facing plane intersects the ray. This means that the ray mightintersect the box, subject to the minimum and maximum distanceconditions described below.

In the example shown in FIG. 4 d the front-facing plane for dimension iwas identified in step S308. In this case the back-facing testdetermines which of the back-facing planes for dimensions j and kintersects the ray least far along the ray. The back-facing test maydetermine whether B_(j)D_(k)>B_(k)D_(j). If B_(j)D_(k)>B_(k)D_(j) thenthe back-facing plane for dimension k intersects the ray less far alongthe ray than where the back-facing plane for dimension j intersects theray; whereas if B_(j)D_(k)<B_(k)D_(j) then the back-facing plane fordimension j intersects the ray less far along the ray than where theback-facing plane for dimension k intersects the ray. IfB_(j)D_(k)=B_(k)D_(j) then either of the back-facing planes fordimensions j or k can be chosen. The mixed-facing test may determinewhether F_(i)D_(near)>B_(near)D_(i), where the dimension (either j or kin this case) for which the back-facing plane is determined to be leastfar along the ray is denoted “near”. If F_(i)D_(near)>B_(near)D_(i) thenthe front-facing plane for dimension i intersects the ray further alongthe ray than where the determined back-facing plane intersects the ray,such that the ray will miss the box; whereas ifF_(i)D_(near)≤B_(near)D_(i) then the front-facing plane for dimension iintersects the ray no further along the ray than where the determinedback-facing plane intersects the ray. This means that the ray mightintersect the box, subject to the minimum and maximum distanceconditions described below.

In the example shown in FIG. 4 e the front-facing plane for dimension jwas identified in step S308. In this case the back-facing testdetermines which of the back-facing planes for dimensions i and kintersects the ray least far along the ray. The back-facing test maydetermine whether B_(i)D_(k)>B_(k)D_(i). If B_(i)D_(k)>B_(k)D_(i) thenthe back-facing plane for dimension k intersects the ray less far alongthe ray than where the back-facing plane for dimension i intersects theray; whereas if B_(i)D_(k)<B_(k)D_(i) then the back-facing plane fordimension i intersects the ray less far along the ray than where theback-facing plane for dimension k intersects the ray. IfB_(i)D_(k)=B_(k)D_(i) then either of the back-facing planes fordimensions i or k can be chosen. The mixed-facing test may determinewhether F_(j)D_(near)>B_(near)D_(j), where the dimension (either i or kin this case) for which the back-facing plane is determined to be leastfar along the ray is denoted “near”. If F_(j)D_(near)>B_(near)D_(j) thenthe front-facing plane for dimension j intersects the ray further alongthe ray than where the determined back-facing plane intersects the ray,such that the ray will miss the box; whereas ifF_(j)D_(near)≤B_(near)D_(j) then the front-facing plane for dimension jintersects the ray no further along the ray than where the determinedback-facing plane intersects the ray. This means that the ray mightintersect the box, subject to the minimum and maximum distanceconditions described below.

Steps S308 and S310 do not involve computing intersection distances toany of the planes of the box. Instead, steps S308 and S310 involveperforming tests (e.g. front-facing tests, back-facing tests andmixed-facing tests) to determine, for a pair of planes, which of theplanes intersects the ray further along the ray. This is achieved inexamples described herein by comparing the values ofcross-multiplications, which does not involve computing intersectiondistances to the planes of the box. Intersection distances do not needto be computed for the box intersection tests performed by the boxintersection testing unit(s) 112. An intersection distance to a plane ofthe box is the distance from the ray origin to the point on the planewhere the ray intersects the plane.

In general, the front-facing tests, back-facing tests and mixed-facingtests described above in relation to steps S308 and S310, which areperformed to determine which of a first plane and a second plane of thebox the ray intersects furthest along the ray, comprise comparing valuesof the form P_(m,i)D_(j) and P_(n,j)D_(i), where P_(m,i) is a componentvalue of the first plane in the ith dimension, where P_(n,j) is acomponent value of the second plane in the jth dimension, and whereD_(i) and D_(j) are components of the direction vector of the ray in theith dimension and jth dimension respectively. In this notation, thevalues of m and n indicate whether the plane is a front-facing plane ora back-facing plane, wherein for front-facing planes the value of m or nmay be 0, and for back-facing planes the value of m or n may be 1. Forexample, P_(0,i)=F_(i), P_(1,i)=B_(i), P_(0,j)=F_(j) and P_(1,j)=B_(j).If P_(m,i)D_(j)>P_(n,j)D_(i) then it is determined that the rayintersects with the first plane (P_(m,i)) further along the ray thanwhere it intersects with the second plane (P_(n,j)), and ifP_(m,i)D_(j)<P_(n,j)D_(i) then it is determined that the ray intersectswith the second plane (P_(n,j)) further along the ray than where itintersects with the first plane (P_(m,i)). Comparisons of this form maybe performed by performing two multiply operations and a compareoperation. These operations are simple to implement (e.g. in hardware),in the box intersection testing unit(s) 112 of the intersection testingmodule.

As described above, in some examples, one or more intermediate resultswhich are determined in step S308 may be stored, and then in step S310the stored one or more intermediate results can be read for use indetermining whether the ray intersects the identified front-facing planebefore it intersects the back-facing planes in the subset of thedimensions. The intermediate results may comprise values of F_(i)D_(j)and F_(i)D_(k) if the front-facing plane in the i^(th) dimension wasidentified in step S308; the intermediate results may comprise values ofF_(j)D_(i) and F_(j)D_(k) if the front-facing plane in the j^(th)dimension was identified in step S308; and the intermediate results maycomprise values of F_(k)D_(j) and F_(k)D_(i) if the front-facing planein the k^(th) dimension was identified in step S308.

Returning to FIG. 3 , at the end of step S310 the intersection testingmodule has determined whether the ray would intersect the axis-alignedbox if the ray were infinitely long. This determination is used todetermine whether the ray intersects the axis-aligned box. It is notedagain that the method determines whether the ray intersects the boxwithout performing a test to determine whether the ray intersects theidentified front-facing plane before it intersects the back-facing planein the dimension for which the front-facing plane was identified. Inthis way, the method described herein avoids performing some of thetests by making some tests conditional on previous results. Furthermore,it is noted again that intersection distances are not computed directlyfor any of the planes of the box.

In examples described above, step S310 includes at most two tests (andin some situations it is possible to just perform one test in step S310,e.g. in the situation shown in FIG. 4 j ). Step S308 includes two orthree tests depending on which approach is taken. Therefore, if thefirst approach to step S308 is used (in which step S308 involvesperforming two tests), the total number of tests is at most four, andmay in some situations, just be three, e.g. in the situation shown inFIG. 4 j ). Furthermore, if the second approach to step S308 is used (inwhich step S308 involves performing three tests), the total number oftests is at most five, and may in some situations, just be four, e.g. inthe situation shown in FIG. 4 j ). If it was determined in step S310that the ray does not intersect the identified front-facing plane at aposition that is no further along the ray than positions at which theray intersects the back-facing planes in the subset of the dimensionsthen it is known that the ray misses the box, and the method passes fromstep S310 to step S316 in which it is determined that the ray misses thebox (i.e. it does not intersect the box). If it is determined in stepS310 that the ray does intersect the identified front-facing plane at aposition that is no further along the ray than positions at which theray intersects the back-facing planes in the subset of the dimensionsthen the method passes to step S312.

In step S312 the intersection testing module 108 (specifically the boxintersection testing unit(s) 112) determines whether a minimum distancecondition and a maximum distance condition are satisfied. The minimumdistance condition is satisfied if a minimum valid distance of the rayfrom the ray origin is less than or equal to a maximum distance from theray origin to any intersection of the ray with a point within the box.In other words, the minimum distance condition is satisfied if the startof the ray (defined by a value of tmin) is not beyond the box whentravelling along the direction vector of the ray. FIG. 5 a shows anexample in which the intersection testing module 108 determines whethera ray 502 intersects a box 504. In step S310 it will be determined thatthe ray 502 intersects the identified front-facing plane of the box 504before it intersects the back-facing planes of the box 504, such thatthe ray 502 may intersect the box 504. In particular the ray 502intersects a front-facing plane of the box 504 at point 506, andintersects a back-facing plane of the box 504 at point 508. In someexamples t_(min)=0 such that the minimum distance of the ray from theray origin is zero, but in the example shown in FIG. 5 a t_(min)≠0. Itis noted that because of the selective reversing of the x, y and zcomponents of the ray and the box in step S306, the direction vector ofthe ray will be in the positive octant, i.e. D_(x)≥0, D_(y)≥0, andD_(z)≥0. In the example shown in FIG. 5 a the minimum valid distance ofthe ray from the ray origin 510 is greater than the maximum distancefrom the ray origin to any intersection of the ray with a point withinthe box, at point 508. Therefore, in this example, in step S312 it willbe determined that the minimum distance condition is not satisfied. Forexample, the determination of whether a minimum distance condition issatisfied may comprise determining whether B_(i)≥D_(i)t_(min),B_(j)≥D_(j)t_(min) and B_(k)≥D_(k)t_(min). As described above, t_(min)is a parameter which defines the minimum valid distance of the ray fromthe ray origin. If all three of B_(i)≥D_(i)t_(min), B_(j)≥D_(j)t_(min)and B_(k)≥D_(k)t_(min) are true then the minimum distance condition issatisfied; whereas if any one of B_(i)<D_(i)t_(min), B_(j)<D_(j)t_(min)and B_(k)<D_(k)t_(min) is true then the minimum distance condition isnot satisfied.

In some examples, t_(min) cannot be negative, and it is also noted thatdue to the selective reversing of the x, y and z components performed instep S306, D_(i)≥0, D_(j)≥0, and D_(k)≥0. Therefore, in these examples,if any of the back-facing planes of the box have negative constantvalues, i.e. if B_(i)<0, B_(j)<0 or B_(k)<0 (i.e. if any of x_(max),y_(max) or z_(max) are negative), then the box is behind the ray, andthus the intersection testing module 108 can determine that the raymisses the box. This determination may be performed at any point afterstep S306, and if this determination determines that the ray misses thebox because the box is behind the ray (which may be referred to as a“pantomime box”) then the method may jump straight to step S316 withoutperforming some or all of the tests described herein in relation tosteps S308, S310 and S312.

In the more general notation used above, B_(i), B_(j) and B_(k) can bedenoted as P_(1,i), P_(1,j) and P_(1,k) respectively. As will becomeapparent after the following description of the maximum distancecondition, it is noted that the maximum distance condition is satisfiedin the example shown in FIG. 5 a because the maximum valid distance ofthe ray from the ray origin at point 512 is greater than the minimumdistance from the ray origin to an intersection of the ray with the boxat point 506.

The maximum distance condition is satisfied if a maximum valid distanceof the ray from the ray origin is greater than or equal to a minimumdistance from the ray origin to any intersection of the ray directionvector with a point within the box. In other words, the maximum distancecondition is satisfied if the end of the ray (defined by a value oft_(max)) is not before the box when travelling along the directionvector of the ray. FIG. 5 b shows an example in which the intersectiontesting module 108 determines whether a ray 522 intersects a box 524. Instep S310 it will be determined that the ray 522 intersects theidentified front-facing plane of the box 524 before it intersects theback-facing planes of the box 524, such that the ray 522 may intersectthe box 524. In particular the ray 522 intersects a front-facing planeof the box 524 at point 526, and intersects a back-facing plane of thebox 524 at point 528. In the example shown in FIG. 5 b the maximum validdistance of the ray from the ray origin 532 is less than the minimumdistance from the ray origin to the intersection of the ray 522 with thefront-facing plane of the box 524 at point 526. Therefore, in thisexample, in step S312 it will be determined that the maximum distancecondition is not satisfied. It is noted that the minimum distancecondition is satisfied in the example shown in FIG. 5 b because theminimum valid distance of the ray from the ray origin at point 530 isless than the maximum distance from the ray origin to any intersectionof the ray with a point within the box, at point 528. In step S308 thefront-facing plane of the box which intersects with the ray furthestalong the ray has been identified, and this identification can be usedto simplify the process of determining whether the maximum distancesatisfied. For example, if the front-facing plane for dimension i isidentified in step S308, where i could be any of the x, y or zdimensions, the test for determining whether a maximum distancecondition is satisfied comprises determining whether F_(i)≤D_(i)t_(max).The other two dimensions can be ignored because it is only the point atwhich the ray intersects the identified front-facing plane that mattersfor the maximum distance condition. As described above, t_(max) is aparameter which defines the maximum valid distance of the ray from theray origin. If F_(i)≤D_(i)t_(max) then the maximum distance condition issatisfied; whereas if F_(i)>D_(i)t_(max) then the maximum distancecondition is not satisfied. In the more general notation used above,F_(i) can be denoted P_(0,i).

FIG. 5 c shows an example in which the intersection testing module 108determines whether a ray 542 intersects a box 544. In step S310 it willbe determined that the ray 542 intersects the identified front-facingplane of the box 544 before it intersects the back-facing planes of thebox 544, such that the ray 542 may intersect the box 544. In particularthe ray 542 intersects a front-facing plane of the box 544 at point 546,and intersects a back-facing plane of the box 544 at point 548. In theexample shown in FIG. 5 c , the minimum distance condition is satisfiedbecause the minimum valid distance of the ray from the ray origin atpoint 550 is less than the maximum distance from the ray origin to anypoint of intersection of the ray with the volume of the box at point548. Also, in the example shown in FIG. 5 c , the maximum distancecondition is satisfied because the maximum valid distance of the rayfrom the ray origin at point 552 is greater than the minimum distancefrom the ray origin to any point of intersection of the ray with thevolume of the box at point 546.

The tests performed in step S312 for determining whether a maximumdistance condition is satisfied and for determining whether a minimumdistance condition is satisfied may be performed in parallel with thetests performed in step S310 for determining whether the ray intersectsthe identified front-facing plane before it intersects the back-facingplanes in a subset of the dimensions. This is because the testsperformed in step S312 do not depend upon the results of the testsperformed in step S310. Performing the tests in parallel may beparticularly beneficial in implementations in which the box intersectiontesting unit(s) 112 are implemented in hardware, (e.g. in fixed functioncircuitry). In other examples (e.g. in which the box intersectiontesting unit(s) 112 are implemented in software, e.g. modules ofcomputer code executed on a processing unit) the tests performed insteps S310 and S312 may be performed sequentially wherein a second ofthe tests is performed only if a first test does not determine a missfor the ray with respect to the box, and a third of the tests isperformed only if the first and second tests do not determine a miss forthe ray with respect to the box, and so on. This sequential approachallows a miss to be determined without necessarily performing all of thetests (if earlier tests in the sequence have determined a miss for theray with respect to the box).

The determinations in step S312 of whether the minimum distancecondition and maximum distance condition are satisfied are used todetermine whether the ray intersects the axis-aligned box. If one orboth of the minimum distance condition and the maximum distancecondition are not satisfied (e.g. in the examples shown in FIGS. 5 a and5 b ) then the method passes from step S312 to step S316 in which theintersection testing module 108 (specifically the box intersectiontesting unit(s) 112) determines that the ray does not intersect the box.However, if both of the minimum distance condition and the maximumdistance condition are satisfied (e.g. in the example shown in FIG. 5 c) then the method passes from step S312 to step S314 in which theintersection testing module 108 (specifically the box intersectiontesting unit(s) 112) determines that the ray does intersect the box. Itis noted that in order to arrive at step S314, i.e. in order for theintersection testing module to determine that the ray intersects theaxis-aligned box, it will have determined that the ray intersects theidentified front-facing plane of the box at a position that is nofurther along the ray than positions at which the ray intersects theback-facing planes of the box (in step S310), and it will havedetermined that maximum distance and minimum distance conditions aresatisfied (in step S312).

Following steps S314 and/or S316 the method passes to step S318 in whichthe intersection testing module 108 outputs an indication of the resultof the determination of whether the ray intersects the box. Thisindication could be a binary indication (e.g. a one-bit flag) toindicate either a ‘hit’ or a ‘miss’ of the ray in respect of the box. Inother examples, the indications could have different forms. In stepS320, the outputted indication is used in the ray tracing system 100(e.g. by the processing logic 110) for rendering an image of a 3D scene.For example, the box may bound geometry to be rendered in a scene. Ifthe box corresponds to a node of a hierarchical acceleration structureto be used for performing intersection testing in the ray tracing systemthen the indication of whether the ray intersects the box can be used todetermine whether to test the ray for intersection with boxescorresponding to any child nodes of the node corresponding to theintersected box. For example, if a ray intersects a box corresponding toa parent node then the ray is tested for intersection with boxescorresponding to the child nodes of that parent node, whereas if a raydoes not intersect a box corresponding to a parent node then the ray isnot tested for intersection with boxes corresponding to the child nodesof that parent node. If a ray intersects a box corresponding to a leafnode of the hierarchical acceleration structure then the ray can betested for intersection with any geometry (e.g. triangles or otherprimitives) that are referenced by the leaf node.

In the example shown in FIG. 3 , the data defining the ray and the boxis read in step S302, and then in step S304 the components of the rayorigin are subtracted from the data defining the position of the box,and then in step S306 the x, y and z components of the ray and the boxare selectively reversed so that D_(x)≥0, D_(y)≥0 and D_(z)>0. However,the ordering of these three steps (steps S302 to S306) may be differentin different examples. For example, the selective reversing of the x, yand z components of the ray and the box data may be performed before thedata is obtained by the intersection testing module 108. It can beuseful to perform this selective reversing of the x, y and z componentsof the data before the data is read in, so that we know that D_(x)≥0,D_(y)≥0 and D_(z)≥0 before the data is read in. This allows somepre-computation of the data to be performed and the pre-computed datacan be stored in a store (e.g. a memory on the ray tracing unit 102)before it is read into the intersection testing module 108. This meansthat the processing involved in this pre-computation can be performedonce for a ray and used multiple times if the ray is involved inmultiple intersection tests. Furthermore, in some examples, thesubtraction of the components of the ray origin from the componentsdefining the positions of the planes of the box could be performed in apre-processing stage, before the data is obtained by the intersectiontesting module 108.

The method is described above for use in a ray tracing system which doesnot introduce any errors into its calculations. However, somecalculations, e.g. calculations performed using numbers in a floatingpoint format may introduce rounding errors. This is partly because theprecision with which floating point numbers can be represented variesfor numbers of different magnitudes. The ‘steps’ between sequentialfloating point numbers are generally approximately proportional to themagnitude of the floating point values (with some exceptions, e.g. inthe neighbourhood of zero). In some examples, the box intersectiontesting unit(s) 112 of the intersection testing module 108 areconfigured to operate conservatively when testing AABBs. In particular,the tests that are performed in steps S308, S310 and S312 can be made tooperate conservatively. This means that the method may sometimes give‘false positive’ results (i.e. it might sometimes indicate that a rayintersects a box even though it does not), but the method will not give‘false negative’ results (i.e. it will not indicate that a ray does notintersect a box when it does in fact intersect the box). False positiveresults will not introduce rendering errors into the ray tracing processbecause if a ray is determined to intersect a box then it will be testedfor intersection against a further object bounded by the box (e.g.another box corresponding to a child node, or a piece of geometry), soit will ultimately be found not to intersect the further object. Falsepositive results may reduce the efficiency of the intersection testingprocess by increasing the number of tests that are performed, but thisis acceptable provided that the proportion of positive results which arefalse positive results (rather than true positive results) is low, e.g.less than 1%. So, a small number of false positive results is acceptablein the ray-box intersection testing process. However, ‘false negative’results may introduce rendering errors into the ray tracing processbecause if a ray is determined to miss a box then it will not be testedfor intersection with a further object bounded by the box even thoughthe ray might actually intersect the further object. Rendering errorsare not normally acceptable, so false negative results are notacceptable in the ray-box intersection testing process.

So in some examples, the determination of whether the ray intersects theaxis-aligned box is performed conservatively by rounding valuesdetermined for front-facing planes towards −∞ and rounding valuesdetermined for back-facing planes towards +∞, such that errorsintroduced by rounding in the determination process cannot cause adetermination that the ray does not intersect the axis-aligned box if aperfectly accurate determination would have determined that the ray doesintersect the axis-aligned box. For example, the multiplicationsinvolving front-facing planes in steps S308, S310 and/or S312 (e.g.F_(i)D_(j) or F_(j)D_(k) to give two examples) are rounded towards asmaller value. Similarly, the subtractions performed in step S304 shouldround down for the positions of the front-facing planes. However, themultiplications involving back-facing planes in steps S308, S310 and/orS312 (e.g. B_(i)D_(j) or B_(j)D_(k) to give two examples) are roundedtowards a larger value. Similarly, the subtractions performed in stepS304 should round up for the positions of the back-facing planes.

In some examples, a top-level acceleration structure (TLAS) may be usedto represent a scene in a world space coordinate system. Nodes of theTLAS correspond to boxes (e.g. AABBs which are aligned to the axes ofthe world space coordinate system) representing regions in the scene. Aset of geometry (e.g. representing an object) may be defined and one ormore instances of the set of geometry can be inserted into respectivepositions within the scene. The set of geometry is defined in aninstance space coordinate system, and a bottom-level accelerationstructure (BLAS) is created with nodes corresponding to boxes (e.g.AABBs which are aligned to the axes of the instance space coordinatesystem) representing regions in the instance space. One or more nodes ofthe TLAS may reference nodes of a BLAS. A ray first traverses nodes ofthe TLAS, wherein if the ray is found to intersect with a node thatreferences a node of a BLAS then the ray can be tested for intersectionwith boxes corresponding to nodes of the BLAS. The intersection testingmodule 108 (e.g. the ray adjustment unit 116) can transform the ray intothe instance space coordinate system in order to be tested forintersection with boxes corresponding to nodes of the BLAS. The boxesdescribed herein could correspond to nodes of a TLAS (i.e. the boxescould be axis-aligned boxes in world space), or the boxes describedherein could correspond to nodes of a BLAS (i.e. the boxes could beaxis-aligned boxes in an instance space).

If one of the components of the ray direction vector is zero (i.e. ifD_(x)=0, D_(y)=0 or D_(z)=0) then the ray is parallel to the front andback facing planes of the box in that dimension. When a plane isparallel to the ray, there are two cases to consider: either the ray isentirely outside of the half space defined by the plane (whichautomatically indicates a miss) or the ray is entirely inside thehalf-space defined by the plane. Because the box test is conservative,the case where the ray lies “in the plane” is deemed as “inside”.

If D_(i)=0, where i is any one or x, y or z, then the ray is entirelyinside the front-facing plane of the box for the i^(th) dimension ifF_(i)≤0; whereas the ray is entirely outside the front-facing plane ofthe box for the i^(th) dimension if F_(i)>0. Furthermore, the ray isentirely inside the back-facing plane of the box for the i^(th)dimension if B_(i)≥0; whereas the ray is entirely outside theback-facing plane of the box for the i^(th) dimension if B_(i)<0. If theray is determined to be entirely outside one or both of the front-facingplane and the back-facing plane then the intersection testing module 108determines that the ray does not intersect the box. This test can beperformed before step S308, and if this test determines that the ray isparallel to, and entirely outside of, a plane of the box then the methodcan go straight to step S316, e.g. without performing one or more of thetests of steps S308, S310 or S312. However, if the ray is parallel tothe planes of the box in the i^(th) dimension but is entirely insideboth the front-facing plane and the back-facing plane for the i^(th)dimension then the ray may still intersect the box. During step S308, ifa front-facing parallel plane is being tested with another front-facingplane to see which intersects the ray furthest along the ray then theother front-facing plane is chosen. If both of the front-facing planesbeing compared in step S308 are parallel, then either can be chosen. Itis not possible for all three front-facing planes to be parallel unlessthe ray direction is invalid. During step S310, a back-facing parallelplane can be ignored, i.e. it is considered that the ray intersects afront-facing plane before the back-facing parallel plane.

In the examples described above, a front-facing plane is identified (instep S308) and then it is determined (in step S310) whether theidentified front-facing plane intersects the ray at a position that isno further along the ray than positions at which the ray intersects theback-facing planes for a subset of the dimensions intersect the ray. Thesame principles can be applied, in alternative embodiments, to methodsin which a back-facing plane is identified and then it is determinedwhether the identified back-facing plane intersects the ray before thefront-facing planes for a subset of the dimensions intersect the ray.Examples of these alternative embodiments are described with referenceto the flow chart shown in FIG. 6 and the illustrations shown in FIGS. 7a to 7 j.

FIG. 6 is a flow chart for a method of performing intersection testingto determine whether the ray 202 intersects the 3D axis-aligned box 204.Although the description below refers to testing whether the ray 202intersects the box 204, the same method can be applied for testingwhether the ray 214 intersects the box 204.

Steps S602, S604 and S606 are the same as steps S302, S304 and S306described above with reference to the flow chart of FIG. 3 . Therefore,in step S602 data defining the ray 202 and the box 204 are obtained atthe intersection testing module 108. In particular, data defining thecomponents of the ray origin and the ray direction are obtained. Thedata defining the box may be data defining the positions of the planesrepresenting the box, e.g. the component values which are constant foreach of the front-facing plane and the back-facing plane in each of thethree dimensions. In step S604, the intersection testing module 108subtracts respective components of the origin of the ray from respectivecomponents defining the positions of the front-facing planes and theback-facing planes of the box. In step S606 the axes for the componentsof the ray and the box are selectively reversed by the intersectiontesting module 108 (e.g. by the ray adjustment unit 116), such thatD_(x)≥0, D_(y)≥0 and D_(z)≥0. At the end of step S606, the intersectiontesting module 108 has determined the values of x_(min), y_(min),z_(min), x_(max), y_(max) and z_(max).

In step S608 the intersection testing module 108 (specifically the oneor more box intersection testing units 112) identifies which of theback-facing planes of the box intersects the ray least far along theray. Two example approaches for identifying which of the back-facingplanes of the box intersects the ray least far along the ray in stepS608 are described in detail below.

A First Approach for Identifying Which of the Back-Facing Planes of theBox Intersects the Ray Least Far Along the Ray in Step S608

In the first approach for performing step S608 described herein, stepS608 comprises: (i) performing a first back-facing test to determinewhich of a first back-facing plane and a second back-facing plane of thebox the ray intersects least far along the ray, and (ii) performing asecond back-facing test to determine which of the determined back-facingplane and a third back-facing plane of the box the ray intersects leastfar along the ray, thereby identifying which of the back-facing planesof the box intersects the ray least far along the ray. In this approach,two tests are performed sequentially. The second test uses the result ofthe first test.

FIGS. 7 a and 7 b illustrate the first back-facing test to determinewhether B_(i)D_(j)>B_(j)D_(i). In particular, FIGS. 7 a and 7 b show anaxis-aligned box 702 with three front-facing planes and threeback-facing planes, as viewed from the viewpoint of the origin of a ray(similar to FIG. 2 b and FIGS. 4 a to 4 j ). The edge 704 defines a line(which is shown as a dashed line) which is where the back-facing planesfor the i^(th) and j^(th) dimensions intersect. Following the firstback-facing test to determine whether B_(i)D_(j)>B_(j)D_(i) it is knownwhich side of the line defined by the edge 704 the ray passes on.Therefore, this comparison can be considered to be an edge test on theedge 704. This comparison can also be considered to be a test of whichof the two back-facing planes (for dimensions i and j) intersects theray least far along the ray. The dotted region to one side of the linedefined by the edge 704 represents a region which it is known that theray does not intersect due to the determination of whetherB_(i)D_(j)>B_(j)D_(i). In other words, the determination of whetherB_(i)D_(j)>B_(j)D_(i) determines that the ray passes somewhere in theundotted region to the other side of the line defined by the edge 704.FIG. 7 a shows the situation in which the ray passes to the right of theline defined by the edge 704, i.e. B_(i)D_(j)>B_(j)D_(i) such that theback-facing plane for dimension j intersects the ray less far along theray than where the back-facing plane for dimension i intersects the ray.In contrast, FIG. 7 b shows the situation in which the ray passes to theleft of the line defined by the edge 704, i.e. B_(i)D_(j)<B_(j)D_(i)such that the back-facing plane for dimension i intersects the ray lessfar along the ray than where the back-facing plane for dimension jintersects the ray. If B_(i)D_(j)=B_(j)D_(i) then either of theback-facing planes for dimensions i and j can be chosen. For example, ifthe ray intersects the line defined by the edge 704 then it can beconsidered to be in both the undotted regions shown in FIGS. 7 a and 7b.

In the second back-facing test, the back-facing plane which wasdetermined to intersect the ray least far along the ray in the firstback-facing test is tested against the remaining back-facing plane todetermine which of back-facing planes of the box intersects the rayleast far along the ray. For example, if it was determined that theback-facing plane for dimension j intersects the ray less far along theray than where the back-facing plane for dimension i intersects the ray(i.e. in the situation shown in FIG. 7 a ) then the second back-facingtest comprises determining whether B_(j)D_(k)>B_(k)D_(j), as illustratedin FIGS. 7 c and 7 d . The edge 706 defines a line (which is shown as adashed line) which is where the back-facing planes for the j^(th) andk^(th) dimensions intersect. Following the second back-facing test todetermine whether B_(j)D_(k)>B_(k)D_(j) it is known which side of theline defined by the edge 706 the ray passes on. Therefore, thiscomparison can be considered to be an edge test on the edge 706. Thiscomparison can also be considered to be a test of which of the twoback-facing planes (for dimensions j and k) intersects the ray least faralong the ray. FIG. 7 c shows the situation in which the ray passesbelow the line defined by the edge 706, i.e. B_(j)D_(k)<B_(k)D_(j) suchthat the back-facing plane for dimension j intersects the ray less faralong the ray than where the back-facing plane for dimension kintersects the ray. Therefore, in the situation shown in FIG. 7 c , stepS608 identifies the back-facing plane for dimension j. In contrast, FIG.7 d shows the situation in which the ray passes above the line definedby the edge 706, i.e. B_(j)D_(k)>B_(k)D_(j) such that the back-facingplane for dimension k intersects the ray less far along the ray thanwhere the back-facing plane for dimension j intersects the ray.Therefore, in the situation shown in FIG. 7 d , step S608 identifies theback-facing plane for dimension k. If B_(j)D_(k)=B_(k)D_(j) then eitherof the back-facing planes for dimensions j and k can be chosen.

If it was determined that the back-facing plane for dimension iintersects the ray less far along the ray than where the back-facingplane for dimension j intersects the ray (i.e. in the situation shown inFIG. 7 b ) then the second back-facing test comprises determiningwhether B_(i)D_(k)>B_(k)D_(i), as illustrated in FIGS. 7 e and 7 f . Theedge 708 defines a line (which is shown as a dashed line) which is wherethe back-facing planes for the i^(th) and k^(th) dimensions intersect.Following the second back-facing test to determine whetherB_(i)D_(k)>B_(k)D_(i) it is known which side of the line defined by theedge 708 the ray passes on. Therefore, this comparison can be consideredto be an edge test on the edge 708. This comparison can also beconsidered to be a test of which of the two back-facing planes (fordimensions i and k) intersects the ray least far along the ray. FIG. 7 eshows the situation in which the ray passes above the line defined bythe edge 708, i.e. B_(i)D_(k)>B_(k)D_(i) such that the back-facing planefor dimension k intersects the ray less far along the ray than where theback-facing plane for dimension i intersects the ray. Therefore, in thesituation shown in FIG. 7 e , step S608 identifies the back-facing planefor dimension k. In contrast, FIG. 7 f shows the situation in which theray passes below the line defined by the edge 708, i.e.B_(i)D_(k)<B_(k)D_(i) such that the back-facing plane for dimension iintersects the ray less far along the ray than where the back-facingplane for dimension k intersects the ray. Therefore, in the situationshown in FIG. 7 f , step S608 identifies the back-facing plane fordimension i. If B_(i)D_(k)=B_(k)D_(i) then either of the back-facingplanes for dimensions i and k can be chosen.

A Second Approach for Identifying Which of the Back-Facing Planes of theBox Intersects the Ray Least Far Along the Ray in Step S608

In the second approach for performing step S608 described herein, stepS608 comprises: (i) performing a first back-facing test to determinewhich of a first back-facing plane and a second back-facing plane of thebox the ray intersects least far along the ray; (ii) performing a secondback-facing test to determine which of the first back-facing plane and athird back-facing plane of the box the ray intersects least far alongthe ray; and (iii) performing a third back-facing test to determinewhich of the second back-facing plane and the third back-facing plane ofthe box the ray intersects least far along the ray. The results of thefirst, second and third back-facing tests are used to identify which ofthe back-facing planes of the box intersects the ray least far along theray. In this second approach, the first, second and third back-facingtests are performed independently of each other (i.e. they do notrequire results from one another), and so these three tests may beperformed in parallel.

This second approach can be considered to be performing threeback-facing tests to test which side of each of the lines defined by thethree edges 704, 706 and 708 the ray passes on. For example, the firstback-facing test may determine whether B_(i)D_(j)>B_(j)D_(i). IfB_(i)D_(j)>B_(j)D_(i) then the back-facing plane for dimension jintersects the ray less far along the ray than where the back-facingplane for dimension i intersects the ray (e.g. the ray passes on theright of the line defined by edge 704); whereas if B_(i)D_(j)<B_(j)D_(i)then the back-facing plane for dimension i intersects the ray less faralong the ray than where the back-facing plane for dimension jintersects the ray (e.g. the ray passes on the left of the line definedby edge 704). The second back-facing test may determine whetherB_(i)D_(k)>B_(k)D_(i). If B_(i)D_(k)>B_(k)D_(i) then the back-facingplane for dimension k intersects the ray less far along the ray thanwhere the back-facing plane for dimension i intersects the ray (e.g. theray passes above the line defined by edge 708); whereas ifB_(i)D_(k)<B_(k)D_(i) then the back-facing plane for dimension iintersects the ray less far along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes below theline defined by edge 708). The third back-facing test may determinewhether B_(j)D_(k)>B_(k)D_(j). If B_(j)D_(k)>B_(k)D_(j) then theback-facing plane for dimension k intersects the ray less far along theray than where the back-facing plane for dimension j intersects the ray(e.g. the ray passes above the line defined by edge 706); whereas ifB_(j)D_(k)<B_(k)D_(j) then the back-facing plane for dimension jintersects the ray less far along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes below theline defined by edge 706). As described above, the results of the first,second and third back-facing tests can be used to identify which of theback-facing planes of the box intersects the ray least far along theray.

In the first approach for performing step S608 described above, twoback-facing tests are performed in series; whereas in the secondapproach for performing step S608 described above, three back-facingtests are performed, and these three tests may be performed in parallel.In some implementations, it may be considered beneficial to reduce thenumber of tests that need to be performed, so the first approach forperforming step S608 may be used because this involves performing twoback-facing tests rather than three. However, in some otherimplementations, it may be considered beneficial to shorten theprocessing pipeline (e.g. to reduce latency), so the second approach forperforming step S608 may be used because the back-facing tests in stepS608 can all be performed in parallel together, rather than performingthe tests in series.

At the end of step S608, the intersection testing module 108 hasidentified which of the back-facing planes of the box the ray intersectsleast far along the ray (e.g. as illustrated in FIGS. 7 c to 7 f ).

In step S610 the intersection testing module 108 (specifically the oneor more box intersection testing units 112) determines whether the rayintersects the front-facing planes in a subset of the dimensions atpositions that are no further along the ray than a position at which theray intersects the identified back-facing plane. The subset ofdimensions comprises the two dimensions for which the back-facing planewas not identified, but the subset of dimensions does not comprise thedimension for which the back-facing plane was identified. This isbecause, as described above, the inventors have realised that for eachdimension, a ray will intersect the front-facing plane of anaxis-aligned box for that dimension before it intersects the back-facingplane of the axis-aligned box for that dimension. This is partly becausethe front-facing plane and back-facing plane of an axis-aligned box fora particular dimension are parallel. So without performing any tests,the intersection testing module 108 can know that the ray 202 intersectsthe identified back-facing plane further along the ray than where itintersects the front-facing plane in the dimension for which theback-facing plane was identified. This realisation allows the number oftests that need to be performed to determine whether a ray intersects anaxis-aligned box to be reduced. Two example approaches for determiningwhether the ray intersects the front-facing planes in a subset of thedimensions before it intersects the identified back-facing plane in stepS610 are described in detail below.

A First Approach for Determining Whether the Ray Intersects theFront-Facing Planes in a Subset of the Dimensions at Positions that areno Further Along the Ray than a Position at Which the Ray Intersects theIdentified Back-Facing Plane in Step S610

In the first approach for performing step S610 described herein, stepS610 comprises: (i) performing a first mixed-facing test to determinewhich of the identified back-facing plane and a first front-facing planeof the box the ray intersects furthest along the ray, wherein the firstfront-facing plane of the box is a front-facing plane for a firstdimension in the subset of dimensions; (ii) performing a secondmixed-facing test to determine which of the identified back-facing planeand a second front-facing plane of the box the ray intersects furthestalong the ray, wherein the second front-facing plane of the box is afront-facing plane for a second dimension in the subset of dimensions;and (iii) using the results of the first and second mixed-facing teststo determine whether the ray intersects the front-facing planes in thesubset of the dimensions at positions that are no further along the raythan a position at which the ray intersects the identified back-facingplane. In this approach, the first and second mixed-facing tests do notdepend upon the results of one another so they may be performed inparallel.

FIGS. 7 g to 7 j illustrate the tests that are performed in step S610 indifferent situations. For example, FIG. 7 g follows on from thesituation shown in FIGS. 7 c in which the back-facing plane fordimension j was identified in step S608. In this case the first andsecond mixed-facing tests determine which side of the lines defined bythe two edges 710 and 712 the ray passes on. For example, the firstmixed-facing test may determine whether F_(k)D_(j)>B_(j)D_(k). This testcorresponds to testing which side of the line defined by the edge 710the ray passes on. If F_(k)D_(j)>B_(j)D_(k) then the front-facing planefor dimension k intersects the ray further along the ray than where theback-facing plane for dimension j intersects the ray (e.g. the raypasses below the line defined by edge 710) such that the ray will missthe box; whereas if F_(k)D_(j)≤B_(j)D_(k) then the front-facing planefor dimension k intersects the ray no further along the ray than wherethe back-facing plane for dimension j intersects the ray (e.g. the raypasses above the line defined by edge 710) such that the ray mightintersect the box. The second mixed-facing test may determine whetherF_(i)D_(j)>B_(j)D_(i). This test corresponds to testing which side ofthe line defined by the edge 712 the ray passes on. IfF_(i)D_(j)>B_(j)D_(i) then the front-facing plane for dimension iintersects the ray further along the ray than where the back-facingplane for dimension j intersects the ray (e.g. the ray passes to theright of the line defined by edge 712) such that the ray will miss thebox; whereas if F_(i)D_(j)≤B_(j)D_(i) then the front-facing plane fordimension i intersects the ray no further along the ray than where theback-facing plane for dimension j intersects the ray (e.g. the raypasses to the left of the line defined by edge 712) such that the raymight intersect the box. It is noted that the values of one or both ofB_(j)D_(k) and B_(j)D_(i) may have been calculated in step S608. Thesevalues may be recalculated in step S610 or they may be saved (e.g. inregisters) during step S608 so that they can be reused in step S610without needing to recalculate them.

As another example, FIGS. 7 h and 7 i follow on from the situationsshown in FIGS. 7 d and 7 e respectively in which the back-facing planefor dimension k was identified in step S608. In these two cases thefirst and second mixed-facing tests determine which side of the linesdefined by the two edges 714 and 716 the ray passes on. For example, thefirst mixed-facing test may determine whether F_(i)D_(k)>B_(k)D_(i).This test corresponds to testing which side of the line defined by theedge 714 the ray passes on. If F_(i)D_(k)>B_(k)D_(i) then thefront-facing plane for dimension i intersects the ray further along theray than where the back-facing plane for dimension k intersects the ray(e.g. the ray passes above the line defined by edge 714) such that theray will miss the box; whereas if F_(i)D_(k)≤B_(k)D_(i) then thefront-facing plane for dimension i intersects the ray no further alongthe ray than where the back-facing plane for dimension k intersects theray (e.g. the ray passes below the line defined by edge 714) such thatthe ray might intersect the box. The second mixed-facing test maydetermine whether F_(j)D_(k)>B_(k)D_(j). This test corresponds totesting which side of the line defined by the edge 716 the ray passeson. If F_(j)D_(k)>B_(k)D_(j) then the front-facing plane for dimension jintersects the ray further along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes above theline defined by edge 716) such that the ray will miss the box; whereasif F_(j)D_(k)≤B_(k)D_(j) then the front-facing plane for dimension jintersects the ray no further along the ray than where the back-facingplane for dimension k intersects the ray (e.g. the ray passes below theline defined by edge 716) such that the ray might intersect the box. Itis noted that the values of one or both of B_(k)D_(i) and B_(k)D_(j) mayhave been calculated in step S608. These values may be recalculated instep S610 or they may be saved (e.g. in registers) during step S608 sothat they can be reused in step S610 without needing to recalculatethem.

For the ray to intersect the box, the ray must intersect both of thefront-facing planes for the subset of dimensions at points that are nofurther from the ray origin than the point at which the ray intersectsthe identified back-facing plane of the box. In examples describedherein, a test does not need to be performed to determine whether theray intersects the identified back-facing plane before it intersects thefront-facing plane for the dimension for which the back-facing plane wasidentified. In some examples (e.g. as described in the precedingparagraph), both the first mixed-facing test and the second mixed-facingtest must pass for a hit to be determined for the ray with respect tothe box, i.e. two tests are performed to determine that the ray does notintersect the identified back-facing plane before the ray intersectsrespective front-facing planes for the two dimensions in the subset ofdimensions. However, in some other examples, in some situations one ofthe mixed-facing tests is not required to be performed. For example, inthe situation shown in FIG. 7 h , only one mixed-facing test is requiredin step S610 (i.e. to test which side of the line defined by the edge714 the ray passes on). If the box intersection testing unit(s) 112 candetermine that the geometry of the box is such that only one test needsto be performed (e.g. in the situation shown in FIG. 7 h but not in thesituation shown in FIG. 7 i ) then only one test needs to be performedin step S610.

As another example, FIG. 7 j follows on from the situation shown in FIG.7 f in which the back-facing plane for dimension i was identified instep S608. In this case the first and second mixed-facing testsdetermine which side of the lines defined by the two edges 718 and 720the ray passes on. For example, the first mixed-facing test maydetermine whether F_(j)D_(i)>B_(i)D_(j). This test corresponds totesting which side of the line defined by the edge 718 the ray passeson. If F_(j)D_(i)>B_(i)D_(j) then the front-facing plane for dimension jintersects the ray further along the ray than where the back-facingplane for dimension i intersects the ray (e.g. the ray passes to theleft of the line defined by edge 718) such that the ray will miss thebox; whereas if F_(j)D_(i)≤B_(i)D_(j) then the front-facing plane fordimension j intersects the ray no further along the ray than where theback-facing plane for dimension i intersects the ray (e.g. the raypasses to the right of the line defined by edge 718) such that the raymight intersect the box. The second mixed-facing test may determinewhether F_(k)D_(i)>B_(i)D_(k). This test corresponds to testing whichside of the line defined by the edge 720 the ray passes on. IfF_(k)D_(i)>B_(i)D_(k) then the front-facing plane for dimension kintersects the ray further along the ray than where the back-facingplane for dimension i intersects the ray (e.g. the ray passes below theline defined by edge 720) such that the ray will miss the box; whereasif F_(k)D_(i)≥B_(i)D_(k) then the front-facing plane for dimension kintersects the ray no further along the ray than where the back-facingplane for dimension i intersects the ray (e.g. the ray passes above theline defined by edge 720) such that the ray might intersect the box. Itis noted that the values of one or both of B_(i)D_(j) and B_(i)D_(k) mayhave been calculated in step S608. These values may be recalculated instep S610 or they may be saved (e.g. in registers) during step S608 sothat they can be reused in step S610 without needing to recalculatethem.

A Second Approach for Determining Whether the Ray Intersects theFront-Facing Planes in a Subset of the Dimensions at Positions that areno Further Along the Ray than a Position at Which the Ray Intersects theIdentified Back-Facing Plane in Step S610

In the second approach for performing step S610 described herein, stepS610 comprises: (i) performing a front-facing test to determine which ofa first front-facing plane and a second front-facing plane of the boxthe ray intersects furthest along the ray, wherein the firstfront-facing plane of the box is a front-facing plane for a firstdimension in the subset of dimensions, and the second front-facing planeof the box is a front-facing plane for a second dimension in the subsetof dimensions; (ii) performing a mixed-facing test to determine which ofthe identified back-facing plane and the determined front-facing planeof the box the ray intersects furthest along the ray; and (iii) usingthe result of the mixed-facing test to determine whether the rayintersects the front-facing planes in the subset of the dimensions atpositions that are no further along the ray than a position at which theray intersects the identified back-facing plane.

In other words, in this approach, the furthest front-facing plane forthe ray is determined, and then the intersection testing module 108determines whether the furthest front-facing plane is further along theray than the closest back-facing plane (i.e. the identified back-facingplane). If it is, then the ray misses the box.

For example, in FIG. 7 c the back-facing plane for dimension j wasidentified in step S608. In this case the front-facing test determineswhich of the front-facing planes for dimensions i and k intersects theray furthest along the ray. The front-facing test may determine whetherF_(i)D_(k)>F_(k)D_(i). If F_(i)D_(k)>F_(k)D_(i) then the front-facingplane for dimension i intersects the ray further along the ray thanwhere the front-facing plane for dimension k intersects the ray; whereasif F_(i)D_(k)<F_(k)D_(i) then the front-facing plane for dimension kintersects the ray further along the ray than where the front-facingplane for dimension i intersects the ray. If F_(i)D_(k)=F_(k)D_(i) theneither of the front-facing planes for dimensions i or k can be chosen.The mixed-facing test may determine whether B_(j)D_(far)>F_(far)D_(j),where the dimension (either i or k in this case) for which thefront-facing plane is determined to be furthest along the ray is denoted“far”. If B_(j)D_(far)<F_(far)D_(j) then the determined front-facingplane intersects the ray further along the ray than where theback-facing plane for dimension j intersects the ray, such that the raywill miss the box; whereas if B_(j)D_(far)≥F_(far)D_(j) then thedetermined front-facing plane intersects the ray no further along theray than where the back-facing plane for dimension j intersects the ray.This means that the ray might intersect the box, subject to the minimumand maximum distance conditions.

In the examples shown in FIGS. 7 d and 7 e the back-facing plane fordimension k was identified in step S608. In these two cases thefront-facing test determines which of the front-facing planes fordimensions i and j intersects the ray furthest along the ray. Thefront-facing test may determine whether F_(i)D_(j)>F_(j)D_(i). IfF_(i)D_(j)>F_(j)D_(i) then the front-facing plane for dimension iintersects the ray further along the ray than where the front-facingplane for dimension j intersects the ray; whereas ifF_(i)D_(j)<F_(j)D_(i) then the front-facing plane for dimension jintersects the ray further along the ray than where the front-facingplane for dimension i intersects the ray. If F_(i)D_(j)=F_(j)D_(i) theneither of the front-facing planes for dimensions i orj can be chosen.The mixed-facing test may determine whether B_(k)D_(far)>F_(far)D_(k),where the dimension (either i orj in this case) for which thefront-facing plane is determined to be furthest along the ray is denoted“far”. If B_(k)D_(far)<F_(far)D_(k) then the determined front-facingplane intersects the ray further along the ray than where theback-facing plane for dimension k intersects the ray, such that the raywill miss the box; whereas if B_(k)D_(far)≥F_(far)D_(k) then thedetermined front-facing plane intersects the ray no further along theray than where the back-facing plane for dimension k intersects the ray.This means that the ray might intersect the box, subject to the minimumand maximum distance conditions.

In the example shown in FIG. 7 f the back-facing plane for dimension iwas identified in step S608. In this the front-facing test determineswhich of the front-facing planes for dimensions j and k intersects theray furthest along the ray. The front-facing test may determine whetherF_(j)D_(k)>F_(k)D_(j). If F_(j)D_(k)>F_(k)D_(j) then the front-facingplane for dimension j intersects the ray further along the ray thanwhere the front-facing plane for dimension k intersects the ray; whereasif F_(j)D_(k)<F_(k)D_(j) then the front-facing plane for dimension kintersects the ray further along the ray than where the front-facingplane for dimension j intersects the ray. If F_(j)D_(k)=F_(k)D_(j) theneither of the front-facing planes for dimensions j or k can be chosen.The mixed-facing test may determine whether B_(i)D_(far)>F_(far)D_(i),where the dimension (either j or k in this case) for which thefront-facing plane is determined to be furthest along the ray is denoted“far”. If B_(i)D_(far)<F_(far)D_(i) then the determined front-facingplane intersects the ray further along the ray than where theback-facing plane for dimension i intersects the ray, such that the raywill miss the box; whereas if B_(i)D_(far)≥F_(far)D_(i) then thedetermined front-facing plane intersects the ray no further along theray than where the back-facing plane for dimension i intersects the ray.This means that the ray might intersect the box, subject to the minimumand maximum distance conditions.

Steps S608 and S610 do not involve computing intersection distances toany of the planes of the box. Instead, steps S608 and S610 involveperforming tests (e.g. front-facing tests, back-facing tests andmixed-facing tests) to determine, for a pair of planes, which of theplanes intersects the ray further along the ray. This is achieved inexamples described herein by comparing the values ofcross-multiplications, which does not involve computing intersectiondistances to the planes of the box. Intersection distances do not needto be computed for the box intersection tests performed by the boxintersection testing unit(s) 112.

As described above, in some examples, one or more intermediate resultswhich are determined in step S608 may be stored, and then in step S610the stored one or more intermediate results can be read for use indetermining whether the ray intersects the front-facing planes in asubset of the dimensions before it intersects the identified back-facingplane in step S610.

Returning to FIG. 6 , at the end of step S610 the intersection testingmodule has determined whether the ray would intersect the axis-alignedbox if the ray were infinitely long. This determination is used todetermine whether the ray intersects the axis-aligned box. It is notedthat the method determines whether the ray intersects the box withoutperforming a test to determine whether the ray intersects thefront-facing plane in the dimension for which the back-facing plane wasidentified before it intersects the identified back-facing plane. Inthis way, the method described herein avoids performing some of thetests by making some tests conditional on previous results. Furthermore,it is noted again that intersection distances are not computed directlyfor any of the planes of the box.

In examples described above, step S610 includes at most two tests (andin some situations it is possible to just perform one test in step S610,e.g. in the situation shown in FIG. 7 h ). Step S608 includes two orthree tests depending on which approach is taken. Therefore, if thefirst approach to step S608 is used (in which step S608 involvesperforming two tests), the total number of tests is at most four, andmay in some situations, just be three, e.g. in the situation shown inFIG. 7 h ). Furthermore, if the second approach to step S608 is used (inwhich step S608 involves performing three tests), the total number oftests is at most five, and may in some situations, just be four, e.g. inthe situation shown in FIG. 7 h ).

If it was determined in step S610 that the ray does not intersect thefront-facing planes in the subset of the dimensions at positions thatare no further along the ray than a position at which the ray intersectsthe identified back-facing plane then it is known that the ray missesthe box, and the method passes from step S610 to step S616 in which itis determined that the ray misses the box (i.e. it does not intersectthe box). If it is determined in step S610 that the ray does intersectthe front-facing planes in the subset of the dimensions at positionsthat are no further along the ray than a position at which the rayintersects the identified back-facing plane then the method passes tostep S612.

Steps S612 to S620 shown in FIG. 6 correspond with steps S312 to S320described above with reference to FIG. 3 . In particular, in step S612the intersection testing module 108 (specifically the box intersectiontesting unit(s) 112) determines whether a minimum distance condition anda maximum distance condition are satisfied. The minimum distancecondition is satisfied if a minimum valid distance of the ray from theray origin is less than or equal to a maximum distance from the rayorigin to any intersection of the ray with a point within the box. Inother words, the minimum distance condition is satisfied if the start ofthe ray (defined by a value of t_(min)) is not beyond the box whentravelling along the direction vector of the ray. In step S608 theback-facing plane of the box which intersects with the ray least faralong the ray has been identified, and this identification can be usedto simplify the process of determining whether the minimum distancesatisfied. For example, if the back-facing plane for dimension i isidentified in step S608, where i could be any of the x, y or zdimensions, the test for determining whether a minimum distancecondition is satisfied comprises determining whether B_(i)≥D_(i)t_(min).The other two dimensions can be ignored because it is only the point atwhich the ray intersects the identified back-facing plane that mattersfor the minimum distance condition. As described above, t_(min) is aparameter which defines the minimum valid distance of the ray from theray origin. If B_(i)≥D_(i)t_(min) then the minimum distance condition issatisfied; whereas if B_(i)<D_(i)t_(min) then the minimum distancecondition is not satisfied. In the more general notation used above,B_(i) can be denoted P_(1,i). As mentioned above, in some examples, ifany of the back-facing planes of the box have negative constant values,i.e. if B_(i)<0, B_(j)<0 or B_(k)<0 (i.e. if any of x_(max), y_(max) orz_(max) are negative), then the box is behind the ray, and thus in theseexamples the intersection testing module 108 can determine that the raymisses the box. This determination may be performed at any point afterstep S606, and if this determination determines that the ray misses thebox because the box is behind the ray (which may be referred to as a“pantomime box”) then the method may jump straight to step S616 withoutperforming some or all of the tests described herein in relation tosteps S608, S610 and S612.

The maximum distance condition is satisfied if a maximum valid distanceof the ray from the ray origin is greater than or equal to a minimumdistance from the ray origin to any intersection of the ray directionvector with a point within the box. In other words, the maximum distancecondition is satisfied if the end of the ray (defined by a value oft_(max)) is not before the box when travelling along the directionvector of the ray. For example, the determination of whether a maximumdistance condition is satisfied may comprise determining whetherF_(i)≤D_(i)t_(max), F_(j)≤D_(j)t_(max) and F_(k)≤D_(k)t_(max). Asdescribed above, t_(max) is a parameter which defines the maximum validdistance of the ray from the ray origin. If all three ofF_(i)≤D_(i)t_(max), F_(j)≤D_(j)t_(max) and F_(k)≤D_(k)t_(max) are truethen the maximum distance condition is satisfied; whereas if any one ofF_(i)>D_(i)t_(max), F_(j)>D_(j)t_(max) and F_(k)>D_(k)t_(max) is truethen the maximum distance condition is not satisfied. In the moregeneral notation used above, F_(i), F_(j) and F_(k) can be denoted asP_(0,i), P_(0,j) and P_(0,k) respectively.

The tests performed in step S612 for determining whether a maximumdistance condition is satisfied and for determining whether a minimumdistance condition is satisfied may be performed in parallel with thetests performed in step S610 for determining whether the ray intersectsthe front-facing planes in a subset of the dimensions before itintersects the identified back-facing plane. This is because the testsperformed in step S612 do not depend upon the results of the testsperformed in step S610. Performing the tests in parallel may beparticularly beneficial in implementations in which the box intersectiontesting unit(s) 112 are implemented in hardware, (e.g. in fixed functioncircuitry) the three comparisons may be performed independently, e.g. inparallel. In other examples (e.g. in which the box intersection testingunit(s) 112 are implemented in software, e.g. modules of computer codeexecuted on a processing unit) the tests performed in steps S610 andS612 may be performed sequentially wherein a second of the tests isperformed only if a first test does not determine a miss for the raywith respect to the box, and a third of the tests is performed only if afirst test does not determine a miss for the ray with respect to thebox, and so on. This sequential approach allows a miss to be determinedwithout necessarily performing all of the tests (if earlier tests in thesequence have determined a miss for the ray with respect to the box).

The determinations in step S612 of whether the minimum distancecondition and maximum distance condition are satisfied are used todetermine whether the ray intersects the axis-aligned box. If one orboth of the minimum distance condition and the maximum distancecondition are not satisfied then the method passes from step S612 tostep S616 in which the intersection testing module 108 (specifically thebox intersection testing unit(s) 112) determines that the ray does notintersect the box. However, if both of the minimum distance conditionand the maximum distance condition are satisfied then the method passesfrom step S612 to step S614 in which the intersection testing module 108(specifically the box intersection testing unit(s) 112) determines thatthe ray does intersect the box. It is noted that in order to arrive atstep S614, i.e. in order for the intersection testing module todetermine that the ray intersects the axis-aligned box, it will havedetermined that the ray intersects the front-facing planes at positionsthat are no further along the ray than a position at which the rayintersects the identified back-facing plane (in step S610), and it willhave determined that maximum distance and minimum distance conditionssatisfied (in step S612).

Following steps S614 and/or S616 the method passes to step S618 in whichthe intersection testing module 108 outputs an indication of the resultof the determination of whether the ray intersects the box. Thisindication could be a binary indication (e.g. a one-bit flag) toindicate either a ‘hit’ or a ‘miss’ of the ray in respect of the box. Inother examples, the indications could have different forms. In stepS620, the outputted indication is used in the ray tracing system 100(e.g. by the processing logic 110) for rendering an image of a 3D scene,e.g. in the same way as described above in relation to step S320.

FIG. 8 shows a computer system in which the ray tracing systemsdescribed herein may be implemented. The computer system comprises a CPU802, a GPU 804, a memory 806 and other devices 814, such as a display816, speakers 818 and a camera 822. A ray tracing unit 810(corresponding to ray tracing unit 102) is implemented on the GPU 804,as well as a Neural Network Accelerator (NNA) 811. In other examples,the ray tracing unit 810 may be implemented on the CPU 802 or within theNNA 811 or as a separate processing unit in the computer system. Thecomponents of the computer system can communicate with each other via acommunications bus 820. A store 812 (corresponding to memory 104) isimplemented as part of the memory 806.

The ray tracing system of FIG. 1 is shown as comprising a number offunctional blocks. This is schematic only and is not intended to definea strict division between different logic elements of such entities.Each functional block may be provided in any suitable manner. It is tobe understood that intermediate values described herein as being formedby a ray tracing system need not be physically generated by the raytracing system at any point and may merely represent logical valueswhich conveniently describe the processing performed by the ray tracingsystem between its input and output.

The ray tracing units, and specifically the intersection testing modulesdescribed herein may be embodied in hardware on an integrated circuit.The intersection testing modules described herein may be configured toperform any of the methods described herein. Generally, any of thefunctions, methods, techniques or components described above can beimplemented in software, firmware, hardware (e.g., fixed logiccircuitry), or any combination thereof. The terms “module,”“functionality,” “component”, “element”, “unit”, “block” and “logic” maybe used herein to generally represent software, firmware, hardware, orany combination thereof. In the case of a software implementation, themodule, functionality, component, element, unit, block or logicrepresents program code that performs the specified tasks when executedon a processor. The algorithms and methods described herein could beperformed by one or more processors executing code that causes theprocessor(s) to perform the algorithms/methods. Examples of acomputer-readable storage medium include a random-access memory (RAM),read-only memory (ROM), an optical disc, flash memory, hard disk memory,and other memory devices that may use magnetic, optical, and othertechniques to store instructions or other data and that can be accessedby a machine.

The terms computer program code and computer readable instructions asused herein refer to any kind of executable code for processors,including code expressed in a machine language, an interpreted languageor a scripting language. Executable code includes binary code, machinecode, bytecode, code defining an integrated circuit (such as a hardwaredescription language or netlist), and code expressed in a programminglanguage code such as C, Java or OpenCL. Executable code may be, forexample, any kind of software, firmware, script, module or librarywhich, when suitably executed, processed, interpreted, compiled,executed at a virtual machine or other software environment, cause aprocessor of the computer system at which the executable code issupported to perform the tasks specified by the code.

A processor, computer, or computer system may be any kind of device,machine or dedicated circuit, or collection or portion thereof, withprocessing capability such that it can execute instructions. A processormay be or comprise any kind of general purpose or dedicated processor,such as a CPU, GPU, NNA, System-on-chip, state machine, media processor,an application-specific integrated circuit (ASIC), a programmable logicarray, a field-programmable gate array (FPGA), or the like. A computeror computer system may comprise one or more processors.

It is also intended to encompass software which defines a configurationof hardware as described herein, such as HDL (hardware descriptionlanguage) software, as is used for designing integrated circuits, or forconfiguring programmable chips, to carry out desired functions. That is,there may be provided a computer readable storage medium having encodedthereon computer readable program code in the form of an integratedcircuit definition dataset that when processed (i.e. run) in anintegrated circuit manufacturing system configures the system tomanufacture an intersection testing module configured to perform any ofthe methods described herein, or to manufacture an intersection testingmodule comprising any apparatus described herein. An integrated circuitdefinition dataset may be, for example, an integrated circuitdescription.

Therefore, there may be provided a method of manufacturing, at anintegrated circuit manufacturing system, an intersection testing moduleas described herein. Furthermore, there may be provided an integratedcircuit definition dataset that, when processed in an integrated circuitmanufacturing system, causes the method of manufacturing an intersectiontesting module to be performed.

An integrated circuit definition dataset may be in the form of computercode, for example as a netlist, code for configuring a programmablechip, as a hardware description language defining hardware suitable formanufacture in an integrated circuit at any level, including as registertransfer level (RTL) code, as high-level circuit representations such asVerilog or VHDL, and as low-level circuit representations such as OASIS®and GDSII. Higher level representations which logically define hardwaresuitable for manufacture in an integrated circuit (such as RTL) may beprocessed at a computer system configured for generating a manufacturingdefinition of an integrated circuit in the context of a softwareenvironment comprising definitions of circuit elements and rules forcombining those elements in order to generate the manufacturingdefinition of an integrated circuit so defined by the representation. Asis typically the case with software executing at a computer system so asto define a machine, one or more intermediate user steps (e.g. providingcommands, variables etc.) may be required in order for a computer systemconfigured for generating a manufacturing definition of an integratedcircuit to execute code defining an integrated circuit so as to generatethe manufacturing definition of that integrated circuit.

An example of processing an integrated circuit definition dataset at anintegrated circuit manufacturing system so as to configure the system tomanufacture an intersection testing module will now be described withrespect to FIG. 9 .

FIG. 9 shows an example of an integrated circuit (IC) manufacturingsystem 902 which is configured to manufacture an intersection testingmodule as described in any of the examples herein. In particular, the ICmanufacturing system 902 comprises a layout processing system 904 and anintegrated circuit generation system 906. The IC manufacturing system902 is configured to receive an IC definition dataset (e.g. defining anintersection testing module as described in any of the examples herein),process the IC definition dataset, and generate an IC according to theIC definition dataset (e.g. which embodies an intersection testingmodule as described in any of the examples herein). The processing ofthe IC definition dataset configures the IC manufacturing system 902 tomanufacture an integrated circuit embodying an intersection testingmodule as described in any of the examples herein.

The layout processing system 904 is configured to receive and processthe IC definition dataset to determine a circuit layout. Methods ofdetermining a circuit layout from an IC definition dataset are known inthe art, and for example may involve synthesising RTL code to determinea gate level representation of a circuit to be generated, e.g. in termsof logical components (e.g. NAND, NOR, AND, OR, MUX and FLIP-FLOPcomponents). A circuit layout can be determined from the gate levelrepresentation of the circuit by determining positional information forthe logical components. This may be done automatically or with userinvolvement in order to optimise the circuit layout. When the layoutprocessing system 904 has determined the circuit layout it may output acircuit layout definition to the IC generation system 906. A circuitlayout definition may be, for example, a circuit layout description.

The IC generation system 906 generates an IC according to the circuitlayout definition, as is known in the art. For example, the ICgeneration system 906 may implement a semiconductor device fabricationprocess to generate the IC, which may involve a multiple-step sequenceof photo lithographic and chemical processing steps during whichelectronic circuits are gradually created on a wafer made ofsemiconducting material. The circuit layout definition may be in theform of a mask which can be used in a lithographic process forgenerating an IC according to the circuit definition. Alternatively, thecircuit layout definition provided to the IC generation system 906 maybe in the form of computer-readable code which the IC generation system906 can use to form a suitable mask for use in generating an IC.

The different processes performed by the IC manufacturing system 902 maybe implemented all in one location, e.g. by one party. Alternatively,the IC manufacturing system 902 may be a distributed system such thatsome of the processes may be performed at different locations, and maybe performed by different parties. For example, some of the stages of:(i) synthesising RTL code representing the IC definition dataset to forma gate level representation of a circuit to be generated, (ii)generating a circuit layout based on the gate level representation,(iii) forming a mask in accordance with the circuit layout, and (iv)fabricating an integrated circuit using the mask, may be performed indifferent locations and/or by different parties.

In other examples, processing of the integrated circuit definitiondataset at an integrated circuit manufacturing system may configure thesystem to manufacture an intersection testing module without the ICdefinition dataset being processed so as to determine a circuit layout.For instance, an integrated circuit definition dataset may define theconfiguration of a reconfigurable processor, such as an FPGA, and theprocessing of that dataset may configure an IC manufacturing system togenerate a reconfigurable processor having that defined configuration(e.g. by loading configuration data to the FPGA).

In some embodiments, an integrated circuit manufacturing definitiondataset, when processed in an integrated circuit manufacturing system,may cause an integrated circuit manufacturing system to generate adevice as described herein. For example, the configuration of anintegrated circuit manufacturing system in the manner described abovewith respect to FIG. 9 by an integrated circuit manufacturing definitiondataset may cause a device as described herein to be manufactured.

In some examples, an integrated circuit definition dataset could includesoftware which runs on hardware defined at the dataset or in combinationwith hardware defined at the dataset. In the example shown in FIG. 9 ,the IC generation system may further be configured by an integratedcircuit definition dataset to, on manufacturing an integrated circuit,load firmware onto that integrated circuit in accordance with programcode defined at the integrated circuit definition dataset or otherwiseprovide program code with the integrated circuit for use with theintegrated circuit.

The implementation of concepts set forth in this application in devices,apparatus, modules, and/or systems (as well as in methods implementedherein) may give rise to performance improvements when compared withknown implementations. The performance improvements may include one ormore of increased computational performance, reduced latency, increasedthroughput, and/or reduced power consumption. During manufacture of suchdevices, apparatus, modules, and systems (e.g. in integrated circuits)performance improvements can be traded-off against the physicalimplementation, thereby improving the method of manufacture. Forexample, a performance improvement may be traded against layout area,thereby matching the performance of a known implementation but usingless silicon. This may be done, for example, by reusing functionalblocks in a serialised fashion or sharing functional blocks betweenelements of the devices, apparatus, modules and/or systems. Conversely,concepts set forth in this application that give rise to improvements inthe physical implementation of the devices, apparatus, modules, andsystems (such as reduced silicon area) may be traded for improvedperformance. This may be done, for example, by manufacturing multipleinstances of a module within a predefined area budget.

The applicant hereby discloses in isolation each individual featuredescribed herein and any combination of two or more such features, tothe extent that such features or combinations are capable of beingcarried out based on the present specification as a whole in the lightof the common general knowledge of a person skilled in the art,irrespective of whether such features or combinations of features solveany problems disclosed herein. In view of the foregoing description itwill be evident to a person skilled in the art that variousmodifications may be made within the scope of the invention.

What is claimed is:
 1. A method of determining, in a ray tracing system,whether a ray intersects a three-dimensional axis-aligned box, whereinthe box represents a volume defined by a front-facing plane and aback-facing plane for each dimension of the three-dimensionalaxis-aligned box, the method comprising: identifying which of thefront-facing planes of the box intersects the ray at a position that isfurthest along a direction of the ray; determining whether the positionat which the ray intersects the identified front-facing plane is nofurther along the ray than positions at which the ray intersects theback-facing planes in a subset of the dimensions, wherein the subset ofdimensions comprises the two dimensions for which the front-facing planewas not identified, but wherein the subset of dimensions does notcomprise the dimension for which the front-facing plane was identified;and determining whether the ray intersects the axis-aligned box independence on the determination of whether the position at which the rayintersects the identified front-facing plane is no further along the raythan positions at which the ray intersects the back-facing planes in thesubset of the dimensions, wherein the method determines whether the rayintersects the box without performing a test to determine whether theposition at which the ray intersects the identified front-facing planeis no further along the ray than a position at which the ray intersectsthe back-facing plane in the dimension for which the front-facing planewas identified.
 2. The method of claim 1 wherein said steps ofidentifying which of the front-facing planes of the box intersects theray at a position that is furthest along a direction of the ray anddetermining whether the position at which the ray intersects theidentified front-facing plane is no further along the ray than positionsat which the ray intersects the back-facing planes in the subset of thedimensions, are performed without computing intersection distances toany of the planes of the box.
 3. The method of claim 1 wherein saididentifying which of the front-facing planes of the box intersects theray at a position that is furthest along the direction of the raycomprises: performing a first front-facing test to determine which of afirst front-facing plane and a second front-facing plane of the box theray intersects furthest along the ray; and performing a secondfront-facing test to determine which of the determined front-facingplane and a third front-facing plane of the box the ray intersectsfurthest along the ray, thereby identifying which of the front-facingplanes of the box intersects the ray furthest along the ray.
 4. Themethod of claim 1 wherein said identifying which of the front-facingplanes of the box intersects the ray at a position that is furthestalong the direction of the ray comprises: performing a firstfront-facing test to determine which of a first front-facing plane and asecond front-facing plane of the box intersects the ray intersects at aposition that is furthest along the ray; performing a secondfront-facing test to determine which of the first front-facing plane anda third front-facing plane of the box intersects the ray at a positionthat is furthest along the direction of the ray; performing a thirdfront-facing test to determine which of the second front-facing planeand the third front-facing plane of the box intersects the ray at aposition that is furthest along the direction of the ray; and using theresults of the first, second and third front-facing tests to identifywhich of the front-facing planes of the box intersects the ray at aposition that is furthest along the direction of the ray.
 5. The methodof claim 1 wherein said determining whether the position at which theray intersects the identified front-facing plane is no further along theray than positions at which the ray intersects the back-facing planes inthe subset of the dimensions comprises: performing a first mixed-facingtest to determine which of the identified front-facing plane and a firstback-facing plane of the box intersects the ray at a position that isfurthest along the direction of the ray, wherein the first back-facingplane of the box is a back-facing plane for a first dimension in thesubset of dimensions; performing a second mixed-facing test to determinewhich of the identified front-facing plane and a second back-facingplane of the box intersects the ray at a position that is furthest alongthe direction of the ray, wherein the second back-facing plane of thebox is a back-facing plane for a second dimension in the subset ofdimensions; and using the results of the first and second mixed-facingtests to determine whether the position at which the ray intersects theidentified front-facing plane is no further along the ray than positionsat which the ray intersects the back-facing planes in the subset of thedimensions.
 6. The method of claim 1 wherein said determining whetherthe position at which the ray intersects the identified front-facingplane is no further along the ray than positions at which the rayintersects the back-facing planes in the subset of the dimensionscomprises: performing a back-facing test to determine which of a firstback-facing plane and a second back-facing plane of the box intersectsthe ray at a position that is the least far along the direction of theray, wherein the first back-facing plane of the box is a back-facingplane for a first dimension in the subset of dimensions, and the secondback-facing plane of the box is a back-facing plane for a seconddimension in the subset of dimensions; performing a mixed-facing test todetermine which of the identified front-facing plane and the determinedback-facing plane of the box intersects the ray at a position that isfurthest along the direction of the ray; and using the result of themixed-facing test to determine whether the position at which the rayintersects the identified front-facing plane is no further along the raythan positions at which the ray intersects the back-facing planes in thesubset of the dimensions.
 7. The method of claim 1 further comprisingperforming a front-facing test, a back-facing test or a mixed-facingtest to determine which of a first plane and a second plane of the boxintersects the ray at a position that is furthest along the direction ofthe ray, comprising: comparing P_(m,i)D_(j); and P_(n,j)D_(i), whereinP_(m,i) is a constant component value of the first plane in the i^(th)dimension, wherein P_(n,j) is a constant component value of the secondplane in the j^(th) dimension, wherein D_(i) and D_(j) are components ofa direction vector of the ray in the i^(th) dimension and j^(th)dimension respectively, wherein either: in response to determining thatP_(m,i)D_(j)>P_(n,j)D_(i), determining that the ray intersects with thefirst plane further along the ray than where the ray intersects with thesecond plane; or in response to determining thatP_(m,i)D_(j)<P_(n,j)D_(i), determining that the ray intersects with thesecond plane further along the ray than where the ray intersects withthe first plane, wherein the first plane is either: (i) the front-facingplane for dimension i and has a component value of P_(0,i) for thei^(th) dimension, or (ii) the back-facing plane for dimension i and hasa component value of P_(1,i) for the i^(th) dimension, and wherein thesecond plane is either: (i) the front-facing plane for dimension j andhas a component value of P_(0,i) for the j^(th) dimension, or (ii) theback-facing plane for dimension j and has a component value of P_(1,i)for the j^(th) dimension.
 8. The method of claim 1 further comprising:storing one or more intermediate results which are determined in saididentifying which of the front-facing planes of the box intersects theray at a position that is furthest along the direction of the ray; andreading the stored one or more intermediate results for use in saiddetermining whether the position at which the ray intersects theidentified front-facing plane is no further along the ray than positionsat which the ray intersects the back-facing planes in the subset of thedimensions.
 9. The method of claim 1 further comprising determiningwhether a maximum distance condition is satisfied, wherein the maximumdistance condition is satisfied if a maximum valid distance of the rayfrom the ray origin is greater than or equal to a minimum distance fromthe ray origin to any intersection of the ray with a point within thebox, wherein said determining whether the ray intersects theaxis-aligned box further comprises using the determination of whetherthe maximum distance condition is satisfied.
 10. The method of claim 1further comprising determining whether a minimum distance condition issatisfied, wherein the minimum distance condition is satisfied if aminimum valid distance of the ray from the ray origin is less than orequal to a maximum distance from the ray origin to any intersection ofthe ray with a point within the box, wherein said determining whetherthe ray intersects the axis-aligned box further comprises using thedetermination of whether the minimum distance condition is satisfied.11. The method of claim 10 further comprising determining whether amaximum distance condition is satisfied, wherein the maximum distancecondition is satisfied if a maximum valid distance of the ray from theray origin is greater than or equal to a minimum distance from the rayorigin to any intersection of the ray with a point within the box,wherein said determining whether the ray intersects the axis-aligned boxfurther comprises using the determination of whether the maximumdistance condition is satisfied, and wherein said determining whether amaximum distance condition is satisfied and said determining whether aminimum distance condition is satisfied are performed in parallel withsaid determining whether the position at which the ray intersects theidentified front-facing plane is no further along the ray than positionsat which the ray intersects the back-facing planes in the subset of thedimensions.
 12. The method of claim 1 further comprising selectivelyreversing the axes for the components of the ray and the axis-alignedbox, such that D_(i)≥0, D_(j)≥0 and D_(k)≥0, before identifying which ofthe front-facing planes of the box intersects the ray at a position thatis furthest along the direction of the ray, wherein D_(i), D_(j), andD_(k) are the components of a direction vector of the ray in the i^(th),j^(th) and k^(th) dimensions respectively.
 13. The method of claim 1wherein the determination of whether the ray intersects the axis-alignedbox is performed conservatively by rounding values determined forfront-facing planes towards −∞ and rounding values determined forback-facing planes towards +∞, such that errors introduced by roundingin the determination process cannot cause a determination that the raydoes not intersect the axis-aligned box if a perfectly accuratedetermination would have determined that the ray does intersect theaxis-aligned box.
 14. A method of determining, in a ray tracing system,whether a ray intersects a three-dimensional axis-aligned box, whereinthe box represents a volume defined by a front-facing plane and aback-facing plane for each dimension of the three-dimensionalaxis-aligned box, the method comprising: identifying which of theback-facing planes of the box intersects the ray at a position that isthe least far along a direction of the ray; determining whether the rayintersects the front-facing planes in a subset of the dimensions atpositions that are no further along the ray than a position at which theray intersects the identified back-facing plane, wherein the subset ofdimensions comprises the two dimensions for which the back-facing planewas not identified, but wherein the subset of dimensions does notcomprise the dimension for which the back-facing plane was identified;and determining whether the ray intersects the axis-aligned box usingthe determination of whether the ray intersects the front-facing planesin the subset of the dimensions at positions that are no further alongthe ray than a position at which the ray intersects the identifiedback-facing plane, wherein the method determines whether the rayintersects the box without performing a test to determine whether theray intersects the front-facing plane in the dimension for which theback-facing plane was identified at a position that is no further alongthe ray than a position at which the ray intersects the identifiedback-facing plane.
 15. The method of claim 14 wherein said identifyingwhich of the back-facing planes of the box intersects the ray at aposition that is the least far along the direction of the ray comprises:performing a first back-facing test to determine which of a firstback-facing plane and a second back-facing plane of the box intersectsthe ray intersects at a position that is the least far along thedirection of the ray; and performing a second back-facing test todetermine which of the determined back-facing plane and a thirdback-facing plane of the box intersects the ray at a position that isthe least far along the direction of the ray, thereby identifying whichof the back-facing planes of the box intersects the ray at a positionthat is the least far along the direction of the ray.
 16. The method ofclaim 14 wherein said identifying which of the back-facing planes of thebox intersects the ray at a position that is the least far along thedirection of the ray comprises: performing a first back-facing test todetermine which of a first back-facing plane and a second back-facingplane of the box intersects the ray at a position that is the least faralong the direction of the ray; performing a second back-facing test todetermine which of the first back-facing plane and a third back-facingplane of the box intersects the ray at a position that is the least faralong the direction of the ray; performing a third back-facing test todetermine which of the second back-facing plane and the thirdback-facing plane of the box intersects the ray at a position that isthe least far along the direction of the ray; and using the results ofthe first, second and third back-facing tests to identify which of theback-facing planes of the box intersects the ray as a position that theleast far along the direction of the ray.
 17. The method of claim 14wherein said determining whether the ray intersects the front-facingplanes in the subset of the dimensions at positions that are no furtheralong the ray than a position at which the ray intersects the identifiedback-facing plane comprises: performing a first mixed-facing test todetermine which of the identified back-facing plane and a firstfront-facing plane of the box intersects the ray at a position that isfurthest along the direction of the ray, wherein the first front-facingplane of the box is a front-facing plane for a first dimension in thesubset of dimensions; performing a second mixed-facing test to determinewhich of the identified back-facing plane and a second front-facingplane of the box intersects the ray at a position that is furthest alongthe direction of the ray, wherein the second front-facing plane of thebox is a front-facing plane for a second dimension in the subset ofdimensions; and using the results of the first and second mixed-facingtests to determine whether the ray intersects the front-facing planes inthe subset of the dimensions at positions that are no further along theray than a position at which the ray intersects the identifiedback-facing plane.
 18. The method of claim 14 wherein said determiningwhether the ray intersects the front-facing planes in the subset of thedimensions at positions that are no further along the ray than aposition at which the ray intersects the identified back-facing planecomprises: performing a front-facing test to determine which of a firstfront-facing plane and a second front-facing plane of the box intersectsthe ray at a position that is furthest along the direction of the ray,wherein the first front-facing plane of the box is a front-facing planefor a first dimension in the subset of dimensions, and the secondfront-facing plane of the box is a front-facing plane for a seconddimension in the subset of dimensions; performing a mixed-facing test todetermine which of the identified back-facing plane and the determinedfront-facing plane of the box intersects the ray at a position that isfurthest along the direction of the ray; and using the result of themixed-facing test to determine whether the ray intersects thefront-facing planes in the subset of the dimensions at positions thatare no further along the ray than a position at which the ray intersectsthe identified back-facing plane.
 19. An intersection testing moduleimplemented in fixed function circuitry, for use in a ray tracingsystem, configured to determine whether a ray intersects athree-dimensional axis-aligned box, wherein the box represents a volumedefined by a front-facing plane and a back-facing plane for eachdimension of the three-dimensional axis-aligned box, the intersectiontesting module being configured to: identify which of the front-facingplanes of the box intersects the ray at a position that is furthestalong a direction of the ray; determine whether the position at whichthe ray intersects the identified front- facing plane is no furtheralong the ray than positions at which the ray intersects the back-facingplanes in a subset of the dimensions, wherein the subset of dimensionscomprises the two dimensions for which the front-facing plane was notidentified, but wherein the subset of dimensions does not comprise thedimension for which the front-facing plane was identified; and determinewhether the ray intersects the axis-aligned box using the determinationof whether the position at which the ray intersects the identifiedfront-facing plane is no further along the ray than positions at whichthe ray intersects the back-facing planes in the subset of thedimensions, wherein the intersection testing module is configured todetermine whether the ray intersects the box without performing a testto determine whether the position at which the ray intersects theidentified front-facing plane is no further along the ray than aposition at which the ray intersects the back-facing plane in thedimension for which the front-facing plane was identified.
 20. Anintersection testing module implemented in fixed function circuitry, foruse in a ray tracing system, configured to determine whether a rayintersects a three-dimensional axis-aligned box, wherein the boxrepresents a volume defined by a front-facing plane and a back-facingplane for each dimension of the three-dimensional axis-aligned box, theintersection testing module being configured to: identify which of theback-facing planes of the box intersects the ray at a position that isthe least far along a direction of the ray; determine whether the rayintersects the front-facing planes in a subset of the dimensions atpositions that are no further along the ray than a position at which theray intersects the identified back-facing plane, wherein the subset ofdimensions comprises the two dimensions for which the back-facing planewas not identified, but wherein the subset of dimensions does notcomprise the dimension for which the back-facing plane was identified;and determine whether the ray intersects the axis-aligned box using thedetermination of whether the ray intersects the front-facing planes inthe subset of the dimensions at positions that are no further along theray than the position at which the ray intersects the identifiedback-facing plane, wherein the intersection testing module is configuredto determine whether the ray intersects the box without performing atest to determine whether the ray intersects the front-facing plane inthe dimension for which the back-facing plane was identified at aposition that is no further along the ray than a position at which theray intersects the identified back-facing plane.